4
votes

In my project we are using validation-api:1.1.0.Final and our project is standard maven web based project. When I am deploying the war to JBOSS it is giving us the following error

Caused by: java.lang.NoSuchMethodError: javax.validation.Configuration.parameterNameProvider(Ljavax/validation/ParameterNameProvider;)Ljavax/validation/Configuration;
           at org.apache.cxf.validation.BeanValidationProvider.initFactoryConfig(BeanValidationProvider.java:102) [cxf-core-3.0.2.jar:3.0.2]
           at org.apache.cxf.validation.BeanValidationProvider.<init>(BeanValidationProvider.java:59) [cxf-core-3.0.2.jar:3.0.2]
           at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.6.0_27]
           at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [rt.jar:1.6.0_27]
           at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [rt.jar:1.6.0_27]
           at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [rt.jar:1.6.0_27]
           at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) [spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]

Seems like JBOSS is inserting its own validation-api-1.0.0.GA-redhat-2 jar and which is causing the issue.

I have tried to below jboss-deployment-structure.xml file and placed it inside WEB-INF/ dir but it does not work

<jboss-deployment-structure>
 <deployment>
     <exclusions>
            <module name="javax.validation.api" />
     </exclusions>
 </deployment>
</jboss-deployment-structure>

I am using JBoss EAP 6.1.1.GA (AS 7.2.1.Final-redhat-10)

Maven

<!-- Validation using Annotations -->
<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.1.0.Final</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>5.1.1.Final</version>
    <!-- <scope>provided</scope> -->
</dependency>
<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.el</artifactId>
    <version>2.2.4</version>
</dependency>

javax module

<module xmlns="urn:jboss:module:1.1" name="javax.validation.api">
  <resources>
      <resource-root path="validation-api-1.1.0.Final.jar"/>
      <!-- Insert resources here -->
  </resources>

  <dependencies>
    <module name="org.jboss.logging"/>
  </dependencies>
</module>

I have been struggling to get it through. Any help would be highly appreciated.

3
On a different project I got spring boot to run with all the goodies using below jboss-deployment-structure.xml - Rohit

3 Answers

0
votes

You will need to exclude the module javaee.api as well since it references javax.validation.api . Check JBOSS_HOME\modules\system\layers\base\javaee\api\main\module.xml , it would contain this:

<module xmlns="urn:jboss:module:1.1" name="javaee.api">
<resources>
    <!-- Insert resources here -->
</resources>

<dependencies>
    ....
    <module name="javax.transaction.api" export="true"/>
    <module name="javax.validation.api" export="true"/>
    ....

    <!-- This one always goes last. -->
    <module name="javax.api" export="true"/>
</dependencies>

Then include other dependencies listed in the above module.xml in your jboss-deployment-structure.xml file which you actually need.

More details can be found here: https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7 (refer to section JBoss Deployment Structure File)

0
votes

I got the same problem with hibernate-validator 5.1.3.Final on jboss-eap-6.0.0. The same exclusion didn't help.

Hardcore resolution:

Upload validation-api-1.1.0.Final.jar to of folder jb*\modules\javax\validation\api\main and join it to module.xml .

0
votes

On a different project I got spring boot to run with all the goodies using below jboss-deployment-structure.xml on the same JBoss

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
        <exclude-subsystems>
            <subsystem name="jaxrs" />
        </exclude-subsystems>
        <dependencies>
            <!-- Exclude JAX-RS: 2. re-import the javaee.api and exclude the JAX-RS 
                classes -->
            <module name="javaee.api">
                <imports>
                    <exclude-set>
                        <path name="javax/ws/rs" />
                        <path name="javax/ws/rs/core" />
                        <path name="javax/ws/rs/ext" />
                        <path name="javax/validation" />
                        <path name="javax/validation/bootstrap" />
                        <path name="javax/validation/constraints" />
                        <path name="javax/validation/groups" />
                        <path name="javax/validation/metadata" />
                        <path name="javax/validation/spi" />
                    </exclude-set>
                </imports>
            </module>
        </dependencies>
        <exclusions>
            <module name="javaee.api" />
            <module name="javax.validation.api" />
            <module name="javax.faces.api" />
            <module name="org.hibernate.validator" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>