Reputation: 4214
I have an application thats deployed on Jboss eap 6.2. It uses hibernate validator 5.1.0 Since jboss ships with its own (older) version of this, I excluded this from my war's classpath using j-boss-deployment-structure.xml like below:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.slf4j"/>
<module name="org.hibernate.validator"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
It solved this problem but gives me this exception now:
Caused by: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
5437 at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:133) [hibernate-validator-5.1.0.Final.jar:5.1.0.Final]
5438 at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:45) [hibernate-validator-5.1.0.Final.jar:5.1.0.Final]
5439 at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:236) [hibernate-validator-5.1.0.Final.jar:5.1.0.Fi nal]
5440 at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:229) [spring-context-3.2.6.RELE ASE.jar:3.2.6.RELEASE]
5441 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571) [spring-bean s-3.2.7.RELEASE.jar:3.2.7.RELEASE]
5442 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509) [spring-beans-3 .2.7.RELEASE.jar:3.2.7.RELEASE]
5443 ... 36 more
So i tried excluding the javax.validation package as well:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="javax.validation"/>
<module name="org.apache.log4j"/>
<module name="org.slf4j"/>
<module name="org.hibernate.validator"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
This doesn't seem to help. Its still giving the same error. Any suggestions/help appreciated
Upvotes: 4
Views: 2469
Reputation: 89
Problem is because of jboss's provided validation-api 1.0, but hibernate-validator is built on 1.1, so you can exclude validation api and dependent modules in jboss-deployment-structure. Note that javaee.api provides this dependency by default, so you may need to include required dependencies manually in <dependency>
block.
<exclusions>
<module name="javaee.api"/>
<module name="javax.validation.api"/>
<module name="javax.faces.api"/>
<module name="org.jboss.resteasy.resteasy-hibernatevalidator-provider"/>
<module name="org.hibernate.validator"/>
</exclusions>
Upvotes: 0
Reputation: 4214
We had a custom validator which was using a method from version 5.1.0:
ctx.buildConstraintViolationWithTemplate(ctx.getDefaultConstraintMessageTemplate()).addPropertyNode
In 4.3.1.Final this method was addNode instead of addPropertyNode
ctx.buildConstraintViolationWithTemplate(...).addNode
Finally to make this work I ended up downgrading my application to 4.3.1.Final. I think this should have been handled by the exclusion in j-boss-deployment-structure.xml, however it doesn't work for some reason.
Upvotes: 2