繁体   English   中英

类加载问题Jboss EAP 6.4

[英]Class loading issue Jboss EAP 6.4

我正在使用Jboss保险丝6.3。它在Jboss EAP 6.4中运行,并且包含应用程序要执行的所有必需模块。 我正在建立一个骆驼战争应用程序。我不想将所有必需的库与战争文件打包在一起,所以我已经提到了在maven pom xml范围内提供的内容。我希望骆驼战争应用程序从jboss eap中获取类我在Jboss-deployment-structure.xml中添加了一个通用模块作为所有骆驼战争应用程序的依赖项,并且我将所需模块添加为通用模块的依赖项,但是仍然无法找到类错误。

1.)我是否需要将模块添加为我的应用程序的依赖项,即使它作为服务器中的模块存在?

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>

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

1) module.xml$JBOSS_HOME/modules/org/springframework/3.2.18 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所需的库:

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 jars中META-INF目录中所需的资源将位于您的类路径中。 您可以在此处找到更多信息。

最后一件事,我注意到您在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")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM