users@jersey.java.net

[Jersey] Re: Enabling bean validation

From: Michal Gajdos <michal.gajdos_at_oracle.com>
Date: Wed, 23 Apr 2014 09:40:57 +0200

Hi Oliver,

where exactly are you trying to call isEnabled method? The method
returns true if ValidationFeature is registered in an application (it's
enough to add jersey-bean-validation on the class-path) AND the
ValidationFeature has been processed (ValidationFeature.configure has
been invoked - this happens during initialization of the app). This
means that if you call isEnabled in ResourceConfig it would return false
(ValidationFeature has not been processed). Similarly this the return
value would be false if you call the method in Features that are
processed BEFORE ValidationFeature. The method would return true when a
request is processed (i.e. in resource method, filters, interceptors, ...).

HTH,
Michal

On 23.04.2014, 08:50 , Oliver B. Fischer wrote:
> Hi,
>
> I try to enable bean validation i a test application with Jersey 2.7.
> I added org.glassfish.jersey.ext:jersey-bean-validation as dependency
> and called
>
> register(ValidationFeature.class);
>
> But if I call
>
> isEnabled(ValidationFeature.class);
>
> it returns false.
>
> So what did I miss? According to the documentation Jersey will enable
> bean validation if it finds the right dependencies in the classpath.
>
> BR, Oliver
>