Resteasy Bean Validation Not Being Invoked

十年热恋 提交于 2019-12-01 17:43:16

Have you done this:

Providing a ValidatorAdapter to RESTEasy

RESTEasy will try to obtain an implementation of ValidatorAdapter through a ContextResolver provider in the classpath. We can provide RESTEasy with an implementation like follow:

@Provider
public class MyValidatorContextResolver implements ContextResolver<ValidatorAdapter> {

   @Override
   public ValidatorAdapter getContext(Class<?> type) {
      return new MyValidator(); 
   }

}

Make sure you have the META-INF/services/javax.ws.rs.Providers defined in your war.

You can use the hibernate validator provided with resteasy-3.0.

Check chapter 48, of the resteasy documentation :

http://docs.jboss.org/resteasy/docs/3.0.0.Final/userguide/html_single/index.html#JBoss AS 6

Running with Resteasy '3.0.6.Final' and Spring '4.1.0.RELEASE'.

The 'resteasy-hibernatevalidator-provider' does not evaluate the @Valid annotated params. Using the 'resteasy-validator-provider-11' makes everything work and as a bonus is using Hiberbate validator '5.0.1.Final' instead of needing a Hibernate validator version 4 when using the 'resteasy-hibernatevalidator-provider'.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!