(JAVA)Wildfly 10 CXF本机依赖模块问题 [英] (JAVA) Wildfly 10 CXF native dependency module issues

查看:287
本文介绍了(JAVA)Wildfly 10 CXF本机依赖模块问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试以相同的方式从wildfly8迁移到wildfly10.我正在升级一些依赖项,例如spring,hibernate和CXF ...,但是我对wildfly的CXF嵌入式模块存在一些问题. 在wildfly上,我在CXF上是2.7.8版本,而在wildfly 10上是3.1.4.

I'm trying to migrate from wildfly8 to wildfly10 .. by the same way i'm upgrade some dependency like spring,hibernate and CXF ... but i have some issue with CXF embedded module from wildfly. on wildfly i was on 2.7.8 version on CXF to 3.1.4 on wildfly 10.

这里是我的pom.xml

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-ws-security</artifactId>
        <version>${cxf.version}</version>
        <scope>provided</scope>
    </dependency>

    <!-- jaxrs is not in wildfly embedded module -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxrs</artifactId>
        <version>${cxf.version}</version>
        <scope>compile</scope>
        <!-- 
        <exclusions>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-bindings-xml</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-core</artifactId>
            </exclusion>
        </exclusions>
         -->
    </dependency>

此处jboss-deployment-structure.xml

<deployment>
    <dependencies>
        <module name="org.apache.cxf" export="true">
            <imports>
                <include path="META-INF**" />
                <include path="META-INF/cxf**" />
            </imports>
        </module>

        <module name="org.apache.cxf.impl" export="true">
            <imports>
                <include path="META-INF**" />
                <include path="META-INF/cxf**" />
            </imports>
        </module>
    </dependencies>
</deployment>

beans.xml用于Web服务配置

    <import resource="classpath:META-INF/cxf/cxf.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-extension-*.xml" />
    <import resource="classpath:META-INF/cxf/**.xml" />
    <bean id="restService" class="com.itoptics.epcmobilereader.webservice.WebService" />
    <bean id="authenticationInterceptor"
class="com.itoptics.epcmobilereader.interceptor.PolicyAuthenticationInterceptor">
    </bean>
    <bean id="authorizationQueryInterceptor"class="org.apache.cxf.interceptor.security.SimpleAuthorizingInterceptor">
        <property name="methodRolesMap">
            <map>
                <entry key="autorisation" value="ROLE_CUSTOMER" />
            </map>
        </property>
    </bean>
    <jaxrs:server id="resteProService" address="/EasyCaseEPC">
        <jaxrs:serviceBeans>
            <ref bean="restService" />
        </jaxrs:serviceBeans>
        <jaxrs:providers>
            <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
        </jaxrs:providers>
     <jaxrs:inInterceptors>
            <ref bean="authenticationInterceptor" />
        </jaxrs:inInterceptors> 
    </jaxrs:server>

最后是我的问题.... NoClassDefFoundError

And finally my issue .... NoClassDefFoundError

Caused by: java.lang.NoClassDefFoundError: Failed to link org/apache/cxf/transport/servlet/CXFServlet (Module "org.apache.cxf.impl:main" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: /home/xxx/Desktop/wildfly-10.0.0.Final/modules,/home/xxx/Desktop/wildfly-10.0.0.Final/modules/system/layers/base))): org/springframework/context/ApplicationListener

此类引用了web.xml

This class refer to web.xml

<servlet>
    <servlet-name>CXFServlet</servlet-name>
    <display-name>CXF Servlet</display-name>
    <servlet-class>
        org.apache.cxf.transport.servlet.CXFServlet
    </servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>

此projet在wildfly 8的CXF 2.7.4上运行良好,当我尝试在wildfly 10上迁移并使用嵌入式CXF时会发生此问题

This projet worked fine on CXF 2.7.4 on wildfly 8 , the problem happen when I tried to migrate on wildfly 10 and using CXF embedded

如果我排除wildfly的模块并嵌入所有依赖项,则Projet可以工作(提供了maven范围编译)

Projet work if I exclude wildfly's module and embeds all dependencies ( maven scope compile instead provided )

我认为问题是由于Wildfly的模块配置错误所致.

I suppose the problem is due to a bad wildfly's module configuration.

感谢您的时间,

关于

推荐答案

在将JBoss 7之间的应用程序迁移到Wildfly 10.1时,我遇到了同样的问题

I had exactly this same problem when migrate app between JBoss 7 to Wildfly 10.1

无法链接org/apache/cxf/transport/servlet/CXFServlet,因为 java.lang.NoClassDefFoundError: org/springframework/context/ApplicationListener

Failed to link org/apache/cxf/transport/servlet/CXFServlet because java.lang.NoClassDefFoundError: org/springframework/context/ApplicationListener

其原因是模块org.apache.cxf.impl没有对模块org.springframework.spring的依赖.

The reason of this is that the module org.apache.cxf.impl hasn't optional dependency on module org.springframework.spring.

在如下所示的模块org.apache.cxf.impl中添加依赖项后,问题消失了.

After adding dependency in module org.apache.cxf.impl like below the problem disappeared.

<module name="org.springframework.spring" optional="true">
    <imports>
        <include path="META-INF"/>
    </imports>
</module>

当然,必须安装org.springframework.spring模块. 我的module.xml(jar和模块取决于您的需要)示例:

Of course, it is necessary to install org.springframework.spring module. My module.xml (jars and modules depends on what you need) example:

<module xmlns="urn:jboss:module:1.1" name="org.springframework.spring">
    <resources>
        <resource-root path="aopalliance-1.0.jar"/>
        <resource-root path="aspectjweaver-1.6.8.jar"/>
        <resource-root path="cglib-2.2.2.jar"/>
        <resource-root path="spring-aop-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-asm-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-beans-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-context-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-context-support-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-core-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-expression-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-jdbc-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-orm-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-tx-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-web-3.1.0.RELEASE.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.mail.api" />
        <module name="javax.faces.api"/>
        <module name="javax.jms.api"/>
        <module name="javax.annotation.api"/>
        <module name="javax.persistence.api"/>
        <module name="javax.activation.api"/>
        <module name="javax.servlet.api"/>
        <module name="org.apache.commons.logging"/>
        <module name="org.jboss.vfs"/>
        <module name="org.hibernate"/>
        <module name="org.hibernate.validator"/>
        <module name="org.hibernate.commons-annotations"/>
        <module name="asm.asm"/>
    </dependencies>
</module>

如果您错过任何一个,那么都会遇到类似问题的异常,但是对于您缺少的类,则必须在spring模块定义中添加适当的jar.

If you miss any then get exception like in question but for your missing class - then have to add proper jar to spring module definition.

然后第二个准备jboss-deployment-structure.xml,我的样子是:

And second prepare jboss-deployment-structure.xml, my look that:

<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.apache.cxf" export="true">
                <imports>
                    <include path="META-INF**"/>
                    <include path="META-INF/cxf**"/>
                </imports>
                <exports>
                    <include path="META-INF"/>
                    <include path="META-INF/cxf"/>
                </exports>
            </module>
            <module name="org.apache.cxf.impl" export="true">
                <imports>
                    <include path="META-INF**"/>
                    <include path="META-INF/cxf**"/>
                </imports>
                <exports>
                    <include path="META-INF"/>
                    <include path="META-INF/cxf"/>
                </exports>
            </module>
            <module name="org.apache.commons.io"/>
            <module name="org.apache.commons.codec"/>
            <module name="org.apache.commons.lang"/>
            <module name="org.apache.commons.beanutils"/>
            <module name="org.apache.commons.collections"/>
            <module  name="org.springframework.spring" export="true" >
                <imports>
                    <include path="META-INF**"/>
                </imports>
                <exports>
                    <include path="META-INF"/>
                </exports>
            </module>
            <module name="org.apache.xerces"/>
            <module name="org.apache.xalan"/>
            <module name="org.slf4j"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure>

这篇关于(JAVA)Wildfly 10 CXF本机依赖模块问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆