NoSuchMethodError on jboss with hibernate 5.1.0.Final validator

I have an application that is deployed on Jboss eap 6.2. It uses hibernate validator 5.1.0 Since jboss comes with its (older) version of this, I excluded this from my warpath using j-boss-deployment-structure.xml as shown 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>

      

He solved this problem but now gives me this exception:

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:

<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>

      

It does not help. It still gives the same error. Any suggestions / help is appreciated

+3


source to share


2 answers


We had a custom validator that used the method from version 5.1.0:

ctx.buildConstraintViolationWithTemplate(ctx.getDefaultConstraintMessageTemplate()).addPropertyNode

      

B 4.3.1. This method was originally addNode instead of addPropertyNode



ctx.buildConstraintViolationWithTemplate(...).addNode

      

Finally, to make this work, I ended up reevaluating my application to 4.3.1.Final. I think this should have been fixed due to an exception in the j-boss-deployment-structure.xml, however for some reason this doesn't work.

+2


source


The problem is that jboss provided validation-api 1.0, but hibernate-validator is built on 1.1, so you can exclude api checks and dependent modules in the jboss-deployment-structure. Note that javaee.api provides this dependency by default, so you may need to include the required dependencies manually in a block <dependency>

.



    <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>

      

0


source







All Articles