jax-rsresteasynhibernate-validator

RestEasy @ValidateRequest is not working


I am having below configuration for a RestEasy Rest WS 

jaxrs-api-2.3.5.Final.jar,
resteasy-jaxrs-2.3.5.Final.jar,
resteasy-hibernatevalidator-provider-2.3.5.Final.jar,
hibernate-validator-4.3.2.Final.jar,
validation-api-1.0.0.GA.jar

I have added @ValidateRequest on class(tried on method as well) to validate any request input data before processing the request but i dont know why validation in not being invoked.

@Path(value = "/events") @ValidateRequest public class EventRestController {

@GET
@Produces({ MediaType.APPLICATION_XML, ACCEPT_HEADER })
public Response get(@QueryParam("componentSerialNumber") @NotNull String componentSerialNumber) {

    System.out.println("powerChangeEvevnt.getComponentSerialNumber()   " +   componentSerialNumber);

    return Response.ok().build();
}

}

i dont know what i am missing. please suggest.


Solution

  • Turning on auto scanning of Rest resources and providers solved the issue, validation started working.

    just set resteasy.scan parameter value to true in web.xml

    i had explicitly registered all resources in a subclass extending javax.ws.rs.Application class but it was not considering HibernateValidator as a validator for validation. i found registering HibernateValidator as a validator quite complex, so just removed this explicitly registered configuration class and enabled Automatically scan.