排除模块在JBoss 7.2.1中不起作用

时间:2014-12-14 06:20:24

标签: java maven jboss jboss7.x

在我的项目中,我们使用的是validation-api:1.1.0.Final,我们的项目是标准的maven基于web的项目。当我将战争部署到JBOSS时,它给了我们以下错误

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]

似乎JBOSS正在插入自己的validation-api-1.0.0.GA-redhat-2 jar,这导致了这个问题。

我已尝试在jboss-deployment-structure.xml文件下面并将其放在WEB-INF / dir中,但它不起作用

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

我正在使用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 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>

我一直在努力实现这一目标。任何帮助都将受到高度赞赏。

3 个答案:

答案 0 :(得分:0)

我在hibernate-validator 5.1.3.Final jboss-eap-6.0.0遇到了同样的问题。同样的排除并没有帮助。

核心分辨率:

validation-api-1.1.0.Final.jar上传到文件夹jb*\modules\javax\validation\api\main并将其加入module.xml

答案 1 :(得分:0)

您需要排除模块javaee.api,因为它引用了javax.validation.api。检查JBOSS_HOME\modules\system\layers\base\javaee\api\main\module.xml,它将包含此内容:

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

然后在module.xml文件中包含上面jboss-deployment-structure.xml中列出的其他依赖项,这些依赖项实际上是您需要的。

更多细节可以在这里找到: https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7 (参见JBoss部署结构文件一节)

答案 2 :(得分:0)

在另一个项目中,我使用同一JBoss上的jboss-deployment-structure.xml下面的所有好东西运行spring boot

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