users@jersey.java.net

[Jersey] Re: Customizing JsonParseExceptionMapper not working

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Wed, 24 Jun 2015 16:36:04 -0700

You need to give your mapper higher priority using @Priority <http://docs.oracle.com/javaee/7/api/javax/annotation/Priority.html> annotation.

Marek

> On 17 Jun 2015, at 22:43, Pritam Moodbidri <pritam_at_yahoo-inc.com> wrote:
>
> Hi,
>
> I am using Jersey 2.18 and Jackson 2.5.3. I am trying to customize, JsonParseExceptionMapper, by the technique documented everywhere. I am using the Provider annotation, and also extending javax.ws.rs.ext.ExceptionMapper, and specifying which exception to map.
>
> What I see is that, there is a race condition that happens. Sometimes, my exception mapper is not used, and the JsonParseExcpetionProvided by Jackson, gets used, and sometimes its the other way around, which differs each time the application gets loaded. I feel this is related to the auto discover feature. Is there any way to make sure my JsonParseExceptionMapper always gets used, without actually having to register that class, for each application.
>
> Thanks
>
> - Pritam