JBoss - 如何在jboss-deployment-structure中排除javax.validation?

时间:2023-01-19 22:07:05

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

我有.war使用Jersey REST,它在tomCat中工作。但我需要在JBoss 6.4.0中运行我的.war,这会导致异常

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.

因为JBoss使用旧版本的javax.validation,我需要从JBoss的部署中排除javax.validation。

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

我在.war的WEB-INF中创建了jboss-deployment-structure.xml:

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

这有助于我排除javax.ws.rs,但如何排除javax.validation?请帮帮我

2 个解决方案

#1


2  

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 dependend have something like that in module.xml:

本身,还有依赖于javax.validation.api模块的模块。最简单的方法是查看哪些模块依赖于javax.validation.api并强制它被包含在内,即使它已被排除,也就是在JBOSS_DIRECTORY / modules中搜索你的.xml文件以获取javax.validation.api,这些模块是dependend在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 :)

然后,javax验证排除工作:)

#2


1  

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

所以,这是一件事!可能对某人有帮助:JBoss中的库javax.validation.api - 属于Implicit模块,有关隐式模块的文档:隐式模块依赖项

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.

所以隐式模块是自动依赖关系,它们可以排除这一点:类提示和自动依赖关系 - 关于自动依赖关系的部分:可以通过使用jboss-deployment-structure.xml排除自动依赖关系。但这不行! :(和JBoss有类似的库javax.persistence的错误,它在任务中打开bug。

So - what can to do?

那么 - 该怎么办?

  1. Update JBoss to 7.0.0 version, but now just Alpha and Beta versions :(
  2. 将JBoss更新到7.0.0版本,但现在只是Alpha和Beta版本:(
  3. Replace old javax.validation.api .jar on new version .jar (in EAP-6.4.0/modules/system/layers/base/javax/faces/api/main)
  4. 在新版本.jar上替换旧的javax.validation.api .jar(在EAP-6.4.0 / modules / system / layers / base / javax / faces / api / main中)
  5. 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.
  6. 添加自定义版本,它纠缠不清:更改EAP-6.4.0 / modules / system / layers / base / javax / faces / api / main module.xml文件中的默认配置,行 remove option export =”true“,result: 这已更改为允许您添加新的自定义库javax.validation。并在EAP-6.4.0 / modules / system / layers / base / javax / validation / api中创建名为1.1的自定义文件夹,放入1.1文件夹new javax.validation .jar和model.xml。

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

params:slot - name自定义文件夹(1.1),path - .jar库的路径

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

上一篇:将模块添加到项目中的jboss-deployment-structure.xml:

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

#1


2  

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 dependend have something like that in module.xml:

本身,还有依赖于javax.validation.api模块的模块。最简单的方法是查看哪些模块依赖于javax.validation.api并强制它被包含在内,即使它已被排除,也就是在JBOSS_DIRECTORY / modules中搜索你的.xml文件以获取javax.validation.api,这些模块是dependend在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 :)

然后,javax验证排除工作:)

#2


1  

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

所以,这是一件事!可能对某人有帮助:JBoss中的库javax.validation.api - 属于Implicit模块,有关隐式模块的文档:隐式模块依赖项

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.

所以隐式模块是自动依赖关系,它们可以排除这一点:类提示和自动依赖关系 - 关于自动依赖关系的部分:可以通过使用jboss-deployment-structure.xml排除自动依赖关系。但这不行! :(和JBoss有类似的库javax.persistence的错误,它在任务中打开bug。

So - what can to do?

那么 - 该怎么办?

  1. Update JBoss to 7.0.0 version, but now just Alpha and Beta versions :(
  2. 将JBoss更新到7.0.0版本,但现在只是Alpha和Beta版本:(
  3. Replace old javax.validation.api .jar on new version .jar (in EAP-6.4.0/modules/system/layers/base/javax/faces/api/main)
  4. 在新版本.jar上替换旧的javax.validation.api .jar(在EAP-6.4.0 / modules / system / layers / base / javax / faces / api / main中)
  5. 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.
  6. 添加自定义版本,它纠缠不清:更改EAP-6.4.0 / modules / system / layers / base / javax / faces / api / main module.xml文件中的默认配置,行 remove option export =”true“,result: 这已更改为允许您添加新的自定义库javax.validation。并在EAP-6.4.0 / modules / system / layers / base / javax / validation / api中创建名为1.1的自定义文件夹,放入1.1文件夹new javax.validation .jar和model.xml。

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

params:slot - name自定义文件夹(1.1),path - .jar库的路径

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

上一篇:将模块添加到项目中的jboss-deployment-structure.xml:

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