类加载问题Jboss EAP 6.4

时间:2017-11-23 15:15:22

标签: maven jboss apache-camel jbossfuse jboss-eap-6

我正在使用Jboss fuse 6.3。它运行在Jboss EAP 6.4中,它包含应用程序执行所需的所有模块。 Iam建立一个骆驼战争应用程序。我不想用war文件打包所有必需的库,所以我已经提到了maven pom xml范围内的提供。我希望camel war应用程序从jboss eap中获取类modules.I有一个公共模块,作为Jboss-deployment-structure.xml中所有camel war应用程序的依赖项添加,我已经添加了所需的模块作为公共模块的依赖项,但仍然发现class not found错误。 / p>

1.)我是否需要将模块添加为我的applcation事件的依赖项,尽管它作为服务器中的模块存在?

2.)你能帮助我找出问题吗?

通用模块xml:

 <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.1" name="com.company.esb">
      <resources>
        <resource-root path="common-0.0.1-SNAPSHOT.jar" />
      </resources>
      <dependencies>
        <module name="javax.xml.bind.api" />
        <module name="org.slf4j" />


        <!-- added all the provided dependencies !-->
         <module name="org.springframework.web" />
     <module name="org.wildfly.extension.camel" />
     <module name="org.wildfly.camel.wildfly-camel-modules" />
     <module name="org.apache.camel.core" />
     <module name="org.apache.camel.spring" />

      </dependencies>
    </module>

的JBoss部署-structure.xml

<?xml version="1.0" encoding="UTF-8"?>  
<jboss-deployment-structure>  
    <deployment>  
         <dependencies>  
              <module name="com.company.esb"/>
        </dependencies>  
    </deployment>  
</jboss-deployment-structure>  

错误日志。

15:12:46,175 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "Component-0.0.1-SNAPSHOT.war" (runtime-name: "Component-0.0.1-SNAPSHOT.war")
15:12:46,637 WARN  [org.jboss.as.ee] (MSC service thread 1-3) JBAS011006: Not installing optional component org.springframework.web.context.ContextLoaderListener due to an exception (enable DEBUG log level to see the cause)
15:12:46,658 INFO  [org.jboss.web] (ServerService Thread Pool -- 88) JBAS018210: Register web context: /Component-0.0.1-SNAPSHOT
15:12:46,669 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Component-0.0.1-SNAPSHOT]] (ServerService Thread Pool -- 88) JBWEB000285: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener from [Module "deployment.Component-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:211) [jboss-modules.jar:1.3.10.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.10.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.10.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.10.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.10.Final-redhat-1]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:78) [jboss-as-web-7.5.17.Final-redhat-4.jar:7.5.17.Final-redhat-4]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3294) [jbossweb-7.5.24.Final-redhat-1.jar:7.5.24.Final-redhat-1]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3780) [jbossweb-7.5.24.Final-redhat-1.jar:7.5.24.Final-redhat-1]
    at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.17.Final-redhat-4.jar:7.5.17.Final-redhat-4]
    at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.17.Final-redhat-4.jar:7.5.17.Final-redhat-4]
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.17.Final-redhat-4.jar:7.5.17.Final-redhat-4]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_151]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_151]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_151]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_151]
    at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_151]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)

15:12:46,674 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Component-0.0.1-SNAPSHOT]] (ServerService Thread Pool -- 88) JBWEB000286: Skipped installing application listeners due to previous error(s)
15:12:46,674 ERROR [org.apache.catalina.core] (ServerService Thread Pool -- 88) JBWEB001103: Error detected during context /Component-0.0.1-SNAPSHOT start, will stop it
15:12:46,675 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 88) MSC000001: Failed to start service jboss.web.deployment.default-host."/Component-0.0.1-SNAPSHOT": org.jboss.msc.service.StartException in service jboss.web.deployment.default-host."/Component-0.0.1-SNAPSHOT": org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:99)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_151]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_151]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_151]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_151]
    at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_151]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context
    at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:168)
    at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61)
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96)
    ... 6 more

15:12:46,679 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) JBAS014612: Operation ("deploy") failed - address: ([("deployment" => "Component-0.0.1-SNAPSHOT.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host.\"/Component-0.0.1-SNAPSHOT\"" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host.\"/Component-0.0.1-SNAPSHOT\": org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context
    Caused by: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context"}}
15:12:46,681 ERROR [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "Component-0.0.1-SNAPSHOT.war" was rolled back with the following failure message: 
{"JBAS014671: Failed services" => {"jboss.web.deployment.default-host.\"/Component-0.0.1-SNAPSHOT\"" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host.\"/Component-0.0.1-SNAPSHOT\": org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context
    Caused by: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context"}}
15:12:46,770 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment Component-0.0.1-SNAPSHOT.war (runtime-name: Component-0.0.1-SNAPSHOT.war) in 88ms
15:12:46,772 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.web.deployment.default-host."/Component-0.0.1-SNAPSHOT"

的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
          http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
           version="2.5">
    <display-name>FTP-JMS</display-name>
    <!-- location of spring xml files -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:META-INF/spring/*.xml</param-value>
    </context-param>
    <!-- the listener that kick-starts Spring -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

模块XML Spring网站:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.springframework.web">
  <resources>
    <resource-root path="spring-web-3.2.18.RELEASE.jar" />
  </resources>
  <dependencies>
    <module name="javax.api" />
    <module name="org.apache.commons.logging" />
    <module name="org.springframework.aop" />
    <module name="org.springframework.beans" />
    <module name="org.springframework.context" />
    <module name="org.springframework.core" />
    <module name="org.springframework.tx" />
    <module name="org.springframework.expression" />

  </dependencies>
</module>

1 个答案:

答案 0 :(得分:1)

我创建了一个简单的实验室,尝试通过在EAP 6.4中创建一个模块以及一个引用该模块的Spring Web应用程序来复制您的问题。

1)module.xml$JBOSS_HOME/modules/org/springframework/3.2.18

<?xml version="1.0"?>
<module xmlns="urn:jboss:module:1.1" name="org.springframework" slot="3.2.18">
    <resources>
            <resource-root path="aopalliance-1.0.jar" />
            <resource-root path="spring-aop-3.2.18.RELEASE.jar" />
            <resource-root path="spring-beans-3.2.18.RELEASE.jar" />
            <resource-root path="spring-context-3.2.18.RELEASE.jar" />
            <resource-root path="spring-context-support-3.2.18.RELEASE.jar" />
            <resource-root path="spring-core-3.2.18.RELEASE.jar" />
            <resource-root path="spring-expression-3.2.18.RELEASE.jar" />
            <resource-root path="spring-web-3.2.18.RELEASE.jar" />
    </resources>
    <dependencies>
            <module name="org.apache.commons.logging" />
            <module name="javaee.api"/>
            <module name="javax.api" export="true" />
            <module name="javax.servlet.api" />
            <module name="org.jboss.vfs" />
    </dependencies>
</module>

在这个目录中,所有Spring Framework都需要libs:

aopalliance-1.0.jar
spring-aop-3.2.18.RELEASE.jar
spring-beans-3.2.18.RELEASE.jar
spring-context-3.2.18.RELEASE.jar
spring-context-support-3.2.18.RELEASE.jar
spring-core-3.2.18.RELEASE.jar
spring-expression-3.2.18.RELEASE.jar
spring-web-3.2.18.RELEASE.jar

2)在jboss-deployment-structure.xml

中引用它
<?xml version="1.0" encoding="UTF-8"?>  
<jboss-deployment-structure>  
    <deployment>  
         <dependencies>  
              <module name="org.springframework" slot="3.2.18" export="true" meta-inf="export"/> 
        </dependencies>  
    </deployment>  
</jboss-deployment-structure>

请注意exportmeta-inf标记。这样,来自Spring jar的META-INF目录所需的资源将在您的类路径中。您可以找到更多信息here

最后一件事,我注意到你在web.xml中使用的是Servlet 2.5版本。这是有原因的吗?尝试使用Servlet 3.0,因为EAP 6.4支持它:

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

结果是成功部署:

11:53:23,808 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of "spring-web-wildfly-0.0.1-SNAPSHOT.war" (runtime-name: "spring-web-wildfly-0.0.1-SNAPSHOT.war")
11:53:23,821 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
11:53:24,071 INFO  [org.jboss.web] (ServerService Thread Pool -- 55) JBAS018210: Register web context: /spring-web-wildfly-0.0.1-SNAPSHOT
11:53:24,110 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/spring-web-wildfly-0.0.1-SNAPSHOT]] (ServerService Thread Pool -- 55) Initializing Spring root WebApplicationContext
11:53:24,117 INFO  [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 55) Root WebApplicationContext: initialization started
11:53:24,176 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (ServerService Thread Pool -- 55) Refreshing Root WebApplicationContext: startup date [Fri Nov 24 11:53:24 BRST 2017]; root of context hierarchy
11:53:24,217 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService Thread Pool -- 55) Loading XML bean definitions from "/content/spring-web-wildfly-0.0.1-SNAPSHOT.war/WEB-INF/classes/META-INF/spring/context.xml"
11:53:24,456 INFO  [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (ServerService Thread Pool -- 55) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
11:53:24,463 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ServerService Thread Pool -- 55) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@17ac5835: defining beans [sayHiImpl,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
11:53:24,482 INFO  [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 55) Root WebApplicationContext: initialization completed in 365 ms
11:53:24,565 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS015859: Deployed "spring-web-wildfly-0.0.1-SNAPSHOT.war" (runtime-name : "spring-web-wildfly-0.0.1-SNAPSHOT.war")