Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JBoss - How can to exclude javax.validation in jboss-deployment-structure?

I have .war using Jersey REST, and it works in tomCat. But I need to run my .war in JBoss 6.4.0 which causes an exception

java.lang.RuntimeException: java.lang.NoSuchMethodError:
javax.validation.spi.ConfigurationState.getParameterNameProvider()

because JBoss uses old version javax.validation, and I need to exclude javax.validation from deployment of JBoss.

I create jboss-deployment-structure.xml in WEB-INF of .war:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>

    <deployment>

        <exclude-subsystems>
            <subsystem name="resteasy" />
            <subsystem name="jpa"/>
            <subsystem name="org.hibernate" />
            <subsystem name="org.hibernate.validator" />
        </exclude-subsystems>

        <exclusions>
            <module name="javaee.api" />
            <module name="javax.ws.rs.api"/>
            <module name="org.jboss.resteasy.resteasy-jaxrs"/>
            <module name="javax.validation.api"/>
            <module name="org.hibernate"/>
            <module name="org.hibernate.validator"/>
        </exclusions>   

    </deployment>
</jboss-deployment-structure>

This helped me to exclude javax.ws.rs, but How can to exclude javax.validation? Help me, please

like image 459
Paushchyk Julia Avatar asked Jan 07 '23 00:01

Paushchyk Julia


2 Answers

Ok, so You need to exclude not only

<module name="javax.validation.api"/> 

itself, but also modules that are dependent on javax.validation.api module. The easiest way to see which modules are dependent on javax.validation.api and force it to be included, even though it was excluded, is to search your .xml files in JBOSS_DIRECTORY/modules for javax.validation.api, the modules that are dependent have something like that in module.xml:

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

And those modules need to be excluded as well. For me - I also needed to exclude:

        <module name="javax.faces.api"/>
        <module name="org.jboss.resteasy.resteasy-hibernatevalidator-provider"/>

And then, javax validation eclusion was working :)

like image 129
maslan Avatar answered Jan 24 '23 20:01

maslan


So, it is something! May be help to someone: Library javax.validation.api in JBoss - belongs to Implicit module, documentation about implicit module: implicit module dependencies

So implicit modules are Automatic Dependencies, and their can exclusion, about this: class lading and automatic dependencies - part about Automatic Dependencies: Automatic dependencies can be excluded through the use of jboss-deployment-structure.xml. But this is not work! :(, and JBoss has bug with similar library javax.persistence, and it bug open in tasks.

So - what can to do?

  1. Update JBoss to 7.0.0 version, but now just Alpha and Beta versions :(
  2. Replace old javax.validation.api .jar on new version .jar (in EAP-6.4.0/modules/system/layers/base/javax/faces/api/main)
  3. Add custom version, and it tangled: change default config in EAP-6.4.0/modules/system/layers/base/javax/faces/api/main module.xml file, in line <module name="javax.validation.api" export="true"/> remove option export="true", result: <module name="javax.validation.api"/> This changed to allow you add a new custom library javax.validation. And create custom folder with name 1.1 in EAP-6.4.0/modules/system/layers/base/javax/validation/api, put in 1.1 folder new javax.validation .jar and model.xml.

model.xml:

<?xml version="1.0" encoding="UTF-8"?>

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

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

params: slot - name custom folder (1.1), path - path to .jar library

Last: add module to jboss-deployment-structure.xml in project:

<dependencies>
  <module name="javax.validation.api" slot="1.1" export="true"/>
</dependencies>
like image 39
Paushchyk Julia Avatar answered Jan 24 '23 22:01

Paushchyk Julia