从 Tomcat 7 迁移到 JBoss7.1

Posted

技术标签:

【中文标题】从 Tomcat 7 迁移到 JBoss7.1【英文标题】:Migration from Tomcat 7 to JBoss7.1 【发布时间】:2013-06-05 16:42:37 【问题描述】:

以前我正在开发一个在 Tomcat 7 服务器上运行的应用程序,但现在我想在 JBoss7.1 服务器上运行它。但是当我试图运行它时。它向我展示了这种错误。我没有得到它是什么以及如何解决它。我在互联网上搜索,但找不到有价值的回复。

我在 JBoss 上的登录是:

09:52:08,117 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "WEB-ERP.war"
09:52:12,994 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."WEB-ERP.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."WEB-ERP.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "WEB-ERP.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.runWorker(Unknown Source) [rt.jar:1.7.0_12-ea]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_12-ea]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_12-ea]
Caused by: java.lang.RuntimeException: Error getting reflective information for class org.apache.struts.taglib.logic.ConditionalTagBase with ClassLoader ModuleClassLoader for Module "deployment.WEB-ERP.war:main" from Service Module Loader
    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: Lorg/apache/struts/util/MessageResources;
    at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.7.0_12-ea]
    at java.lang.Class.privateGetDeclaredFields(Unknown Source) [rt.jar:1.7.0_12-ea]
    at java.lang.Class.getDeclaredFields(Unknown Source) [rt.jar:1.7.0_12-ea]
    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.apache.struts.util.MessageResources from [Module "deployment.WEB-ERP.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    ... 15 more

09:52:13,053 INFO  [org.jboss.as] (MSC service thread 1-2) JBAS015951: Admin console listening on http://127.0.0.1:9990
09:52:13,055 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "WEB-ERP.war" was rolled back with failure message "JBAS014671: Failed services" => "jboss.deployment.unit.\"WEB-ERP.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"WEB-ERP.war\".POST_MODULE: Failed to process phase POST_MODULE of deployment \"WEB-ERP.war\""
09:52:13,056 ERROR [org.jboss.as] (MSC service thread 1-2) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 10052ms - Started 140 of 218 services (1 services failed or missing dependencies, 76 services are passive or on-demand)
09:52:13,107 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment WEB-ERP.war in 51ms
09:52:13,110 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit."WEB-ERP.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."WEB-ERP.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "WEB-ERP.war"

09:52:13,116 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.\"WEB-ERP.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"WEB-ERP.war\".POST_MODULE: Failed to process phase POST_MODULE of deployment \"WEB-ERP.war\""

我收到的错误消息是 The requested resource (/StrutsHelloWorld/) is not available. 我正在开发 Struts 2 和 Hibernate 4 集成应用程序,该应用程序在 Tomcat 上运行良好。

【问题讨论】:

【参考方案1】:

您缺少 Struts 类:它们可能位于 Tomcat 类路径中。您应该确保将 Struts 库添加到您的 WAR 文件中。

【讨论】:

在打包 Web 应用程序之前将 struts jar 放入您的 WEB-INF/lib 文件夹,然后将其重新部署到 JBoss。 我没有创建任何 war 文件,它是 eclipse id 中的简单 Web 项目。 jar 文件已经在 WEB-INF/lib 好吧,看看您的错误,Eclipse 似乎正在创建一个 WAR 文件 (deployment.WEB-ERP.war) 以部署到 JBoss,并且不包括 WEB-INF\lib 目录中的部分或全部文件夹。不确定您使用什么工具在 JBoss 中运行,但您需要检查输出 WAR 文件中包含哪些文件(如果它确实在生成 WAR 文件)或类路径是什么(如果是将解压后的目录作为 Web 应用程序启动 JBoss)。【参考方案2】:

该项目对 Struts1 库具有类路径依赖性。您应该包括 Struts1 库或排除引用 org.apache.struts.util.MessageResources 的依赖项。此类在以下 jar 中找到:

struts-core-1.3.10.jar

【讨论】:

以上是关于从 Tomcat 7 迁移到 JBoss7.1的主要内容,如果未能解决你的问题,请参考以下文章

从 Tomcat 7 迁移到 JBoss7.1

应用程序从 java 6 迁移到 java 7

为啥从 Tomcat 6.0 移植 JBoss-7.2.0 应用程序后无法运行?

无法将 JSF + CDI 项目从 Tomcat 迁移到 Wildfly

如何将 SSL 从 Tomcat 迁移到 Apache HTTPD?

将应用程序从websphere迁移到tomcat