gpt4 book ai didi

java - (JAVA) Wildfly 10 CXF 原生依赖模块问题

转载 作者:行者123 更新时间:2023-11-30 10:49:27 26 4
gpt4 key购买 nike

我正在尝试从 wildfly8 迁移到 wildfly10 .. 以同样的方式升级一些依赖项,如 spring、hibernate 和 CXF ......但我对来自 wildfly 的 CXF 嵌入式模块有一些问题。在 wildfly 上,我在 CXF 上使用 2.7.8 版本,在 wildfly 10 上使用 3.1.4。

这里是我的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

    <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

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

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

此项目在 wildfly 8 上的 CXF 2.7.4 上运行良好,当我尝试在 wildfly 10 上迁移并使用 CXF embedded 时出现问题

如果我排除 wildfly 的模块并嵌入所有依赖项(改为提供 maven scope 编译),则项目工作

我想这个问题是由于 wildfly 的模块配置错误造成的。

谢谢你的时间,

问候,

最佳答案

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

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

这是因为模块 org.apache.cxf.impl 没有对模块 org.springframework.spring 的可选依赖。

像下面这样在模块 org.apache.cxf.impl 中添加依赖项后,问题就消失了。

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

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

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

如果你错过了任何一个,那么就会得到异常,但对于你缺少的类——然后必须将适当的 jar 添加到 spring 模块定义中。

然后准备jboss-deployment-structure.xml,我看是:

<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 - (JAVA) Wildfly 10 CXF 原生依赖模块问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35434293/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com