我们希望从运行时加载JBOSS AS 7.1.1中排除CXF模块,以便我们可以使用在我们的pom中声明的CXF 2.7.8依赖项。我们没有权限更改JBoss的配置,因此从standalone.xml中删除子系统或从JBoss中删除模块是不可能的。我们也坚持使用JBoss 7.1.1,目前无法升级。
我们尝试按如下方式配置jboss-deployment-structure.xml。由于'排除子系统'功能和部署结构:1.2不受JBoss AS 7.1.1的支持,我们尝试了这种替代方法但没有成功:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.apache.cxf" export="true" />
</dependencies>
<exclusions>
<module name="asm.asm" />
<module name="javax.api" />
<module name="javax.annotation.api" />
<module name="javax.jms.api" />
<module name="javax.jws.api" />
<module name="javax.mail.api" />
<module name="javax.resource.api" />
<module name="javax.servlet.api" />
<module name="javax.xml.bind.api"/>
<module name="com.sun.xml.bind"/>
<module name="javax.wsdl4j.api" />
<module name="javax.xml.soap.api" />
<module name="javax.xml.stream.api" />
<module name="javax.xml.ws.api" />
<module name="org.apache.commons.lang" />
<module name="org.apache.neethi" />
<module name="org.apache.velocity" />
<module name="org.apache.xml-resolver" />
<module name="org.apache.ws.xmlschema" />
<module name="org.apache.ws.security" />
<module name="org.apache.santuario.xmlsec" />
<module name="org.springframework.spring"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
栈跟踪
14:24:14,429 WARN [org.jboss.as.server.deployment] (MSC service thread 1-2) Class Path entry jaxb-api.jar in "/F:/Desenvolvimento/Programas/jboss-as-7.1.1.Final_Clean/jboss-as-7.1.1.Final/standalone/deployments/Test.war/WEB-INF/lib/jaxb-impl-2.2.6.jar" does not point to a valid jar for a Class-Path reference.
14:24:14,618 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015893: Encountered invalid class name 'org.xmlpull.mxp1.MXParser,org.xmlpull.mxp1_serializer.MXSerializer' for service type 'org.xmlpull.v1.XmlPullParserFactory'
14:24:14,791 WARN [org.jboss.as.dependency.private] (MSC service thread 1-8) JBAS018567: Deployment "deployment.Test.war" is using a private module ("org.apache.cxf:main") which may be changed or removed in future versions without notice.
14:24:14,793 WARN [org.jboss.as.dependency.private] (MSC service thread 1-8) JBAS018567: Deployment "deployment.Test.war" is using a private module ("org.apache.cxf:main") which may be changed or removed in future versions without notice.
14:24:14,840 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit."Test.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."Test.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "Test.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_45]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_45]
Caused by: java.lang.RuntimeException: Error getting reflective information for class org.apache.cxf.transport.servlet.CXFServlet with ClassLoader ModuleClassLoader for Module "org.apache.cxf:main" from local module loader @5e2b323e (roots: F:\Desenvolvimento\Programas\jboss-as-7.1.1.Final_Clean\jboss-as-7.1.1.Final\modules)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:58)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:85)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:70)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:55)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.6.0_45]
at java.lang.Class.privateGetDeclaredFields(Class.java:2300) [rt.jar:1.6.0_45]
at java.lang.Class.getDeclaredFields(Class.java:1745) [rt.jar:1.6.0_45]
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 10 more
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext from [Module "org.apache.cxf:main" from local module loader @5e2b323e (roots: F:\Desenvolvimento\Programas\jboss-as-7.1.1.Final_Clean\jboss-as-7.1.1.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
... 15 more
14:24:14,871 INFO [org.jboss.as] (MSC service thread 1-4) JBAS015951: Admin console listening on http://127.0.0.1:9990
14:24:14,873 ERROR [org.jboss.as] (MSC service thread 1-4) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 5959ms - Started 140 of 218 services (1 services failed or missing dependencies, 76 services are passive or on-demand)
14:24:14,873 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "Test.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"Test.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"Test.war\".POST_MODULE: Failed to process phase POST_MODULE of deployment \"Test.war\""}}
14:24:15,243 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015877: Stopped deployment Test.war in 368ms
14:24:15,247 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.deployment.unit."Test.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."Test.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "Test.war"
14:24:15,254 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"Test.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"Test.war\".POST_MODULE: Failed to process phase POST_MODULE of deployment \"Test.war\""}}}}
我们的pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.gid.ws</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>br.com.gid.ws</name>
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<org.springframework.version>3.0.7.RELEASE</org.springframework.version>
<org.apache.cxf.version>2.7.8</org.apache.cxf.version>
</properties>
<dependencies>
<!--
################################################
#################### SPRING ####################
################################################
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>1.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>br.com.caelum.stella</groupId>
<artifactId>caelum-stella-core</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15</artifactId>
<version>1.46</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>net.vidageek</groupId>
<artifactId>mirror</artifactId>
<version>1.6.1</version>
</dependency>
<!--
################################################
##################### CXF ######################
################################################
-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${org.apache.cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${org.apache.cxf.version}</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${org.apache.cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-rm</artifactId>
<version>${org.apache.cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${org.apache.cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-addr</artifactId>
<version>${org.apache.cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-policy</artifactId>
<version>${org.apache.cxf.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>8.1.14.v20131031</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
<finalName>Test</finalName>
</build>
</project>
答案 0 :(得分:1)
这对我有用,复制自https://docs.jboss.org/author/display/AS72/Class+Loading+in+AS7
<?xml version="1.0"?>
<exclusions>
<module name="javaee.api"/>
</exclusions>
<dependencies>
<module name="javax.activation.api" export="true"/>
<module name="javax.annotation.api" export="true"/>
<module name="javax.ejb.api" export="true"/>
<module name="javax.el.api" export="true"/>
<module name="javax.enterprise.api" export="true"/>
<module name="javax.enterprise.deploy.api" export="true"/>
<module name="javax.inject.api" export="true"/>
<module name="javax.interceptor.api" export="true"/>
<module name="javax.jms.api" export="true"/>
<module name="javax.jws.api" export="true"/>
<module name="javax.mail.api" export="true"/>
<module name="javax.management.j2ee.api" export="true"/>
<module name="javax.persistence.api" export="true"/>
<module name="javax.resource.api" export="true"/>
<module name="javax.rmi.api" export="true"/>
<module name="javax.security.auth.message.api" export="true"/>
<module name="javax.security.jacc.api" export="true"/>
<module name="javax.servlet.api" export="true"/>
<module name="javax.servlet.jsp.api" export="true"/>
<module name="javax.transaction.api" export="true"/>
<module name="javax.validation.api" export="true"/>
<!-- <module name="javax.ws.rs.api" export="true" services="export"/> -->
<module name="javax.xml.bind.api" export="true"/>
<module name="javax.xml.registry.api" export="true"/>
<module name="javax.xml.soap.api" export="true"/>
<module name="javax.xml.ws.api" export="true"/>
<!-- This one always goes last. -->
<module name="javax.api" export="true"/>
</dependencies>
答案 1 :(得分:0)
理论上,应用程序的类加载器优于层次结构中的任何其他类加载器。在应用程序的lib目录中打包CXF并使用它应该没有问题。
您是否面临这种方法的任何问题?