I have a simple restful web service that uses Bean Validation 1.1 (and Hibernate Validator 5.1.3 as the implementation) and I'm deploying it on JBoss EAP 6.4.0. Since JBoss 6.4 comes bundled with Bean Validation 1.0 and its implementation library (Hibernate Validator 4.3.2), there is a conflict and none of service calls work. Below is the error that I get:
java.lang.NoSuchMethodError: javax.validation.Validator.forExecutables()Ljavax/validation/executable/ExecutableValidator;
org.apache.cxf.validation.BeanValidationProvider.getExecutableValidator(BeanValidationProvider.java:153)
org.apache.cxf.validation.BeanValidationProvider.validateReturnValue(BeanValidationProvider.java:124)
org.apache.cxf.validation.BeanValidationOutInterceptor.handleValidation(BeanValidationOutInterceptor.java:45)
org.apache.cxf.validation.AbstractValidationInterceptor.handleMessage(AbstractVa
The class/method that's referenced above in the exception is only available in validation api 1.1. Hence, I want to exclude the modules 'javax.validation.api' and 'org.hibernate.validator' that's provided by JBoss, so that the jars that are bundled within the war file can be used instead. For that, I created a jboss-deployment-structure.xml file with the below contents and placed it in the app's WEB-INF folder:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="javax.validation.api" />
<module name="org.hibernate.validator" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Now, I get this error instead:
java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:135)
org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:45)
org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:236)
javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
What am I doing wrong? How can I get bean validation 1.1 to work in JBoss 6.4.0?
Warning in JBoss EAP all jee api are provided by a single module : javaee.api So if you want to upgrade only one you need to exclude javaee.api and reinclude all others. So use following jboss-deployment-structure.xml