users@jersey.java.net

[Jersey] Re: Changed behaviour for ExceptionMapper in Jersey 2.2 compared to Jersey 2.1

From: Libor Kramolis <libor.kramolis_at_oracle.com>
Date: Mon, 21 Oct 2013 13:33:25 +0200

Hi Jonas.

Unfortunately the implementation has changed and exception thrown from ConfiguredValidator has to extend ViolationException to mapped by ExceptionMapper.

And be aware of implementing ConfiguredValidator this is Jersey internal API, not a public API. Please create new feature request if you want to integration another validation implementation/framework. I try to explain you use cases or motivation not to use Bean Validation.

Thanks.

-lk


On Sep 3, 2013, at 1:36 PM, Jonas Oscarsson <jonas.osc_at_rsson.nu> wrote:

> Hi,
>
> Don't know if this is the right place to ask about this, but if it isn't please direct me.
>
> I recently upgraded to Jersey 2.2 and found that my custom ExceptionMapper stopped working for my custom ValidationExceptions.
>
> In my implementation of AbstractBinder I have
> bind(ConfiguredValidatorImpl.class).to(ConfiguredValidator.class);
>
> The ConfiguredValidtorImpl is a custom implementation of the Jersey interface ConfiguredValidator. The custom ConfiguredValidatorImpl implements validateResourceAndInputParams() and throws exceptions inheriting from my custom ValidationException (such as BadFieldException or MissingFieldException). I have then configured an ExceptionMapper for ValidationException, writing a custom response when this exception occurs.
>
> This works as intended in Jersey 2.0 and Jersey 2.1, but after upgrade to Jersey 2.2 the ExceptionMapper is not invoked.
>
> Has there been any changes to ExceptionMapper logic in Jersey 2.2? Does anyone know of a possible cause for my particular case to stop working?
>
> Let me know if I need to clarify anything.
>
> / Jonas