0

我尝试使用 eclipse 和 maven 作为依赖解析器部署 Web 应用程序。但我看到了例外:

    00:05:31,883 WARN  [org.jboss.as.ee] (MSC service thread 1-6) JBAS011006: Not installing optional component org.springframework.web.context.ContextLoaderListener due to exception: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener from [Module "deployment.SpringMVCreName.war:main" from Service Module Loader]
    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.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]
    at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_09]
    at java.lang.Class.forName(Class.java:264) [rt.jar:1.7.0_09]
    at org.jboss.as.server.deployment.reflect.DeploymentClassIndex.classIndex(DeploymentClassIndex.java:54) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:79)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [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(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_09]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_09]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]

00:05:31,892 WARN  [org.jboss.as.ee] (MSC service thread 1-6) JBAS011006: Not installing optional component org.springframework.web.servlet.DispatcherServlet due to exception: java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet from [Module "deployment.SpringMVCreName.war:main" from Service Module Loader]
    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.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]
    at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_09]
    at java.lang.Class.forName(Class.java:264) [rt.jar:1.7.0_09]
    at org.jboss.as.server.deployment.reflect.DeploymentClassIndex.classIndex(DeploymentClassIndex.java:54) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:79)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [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(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_09]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_09]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]

00:05:32,007 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SpringMVCreName]] (MSC service thread 1-5) Error configuring application listener of class org.springframework.web.context.ContextLoaderListener: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener from [Module "deployment.SpringMVCreName.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)
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3342) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_09]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_09]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]

00:05:32,024 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SpringMVCreName]] (MSC service thread 1-5) Skipped installing application listeners due to previous error(s)
00:05:32,029 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-5) Error listenerStart
00:05:32,029 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-5) Context [/SpringMVCreName] startup failed due to previous errors
00:05:32,041 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.web.deployment.default-host./SpringMVCreName: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./SpringMVCreName: JBAS018040: Failed to start context
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
    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(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_09]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_09]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]

00:05:32,047 INFO  [org.jboss.as] (MSC service thread 1-5) JBAS015951: Admin console listening on http://127.0.0.1:9990
00:05:32,048 ERROR [org.jboss.as] (MSC service thread 1-5) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 3974ms - Started 170 of 249 services (2 services failed or missing dependencies, 76 services are passive or on-demand)
00:05:32,252 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "SpringMVCreName.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./SpringMVCreName" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./SpringMVCreName: JBAS018040: Failed to start context"}}
00:05:32,278 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment SpringMVCreName.war in 26ms
00:05:32,280 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.web.deployment.default-host./SpringMVCreName: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./SpringMVCreName: JBAS018040: Failed to start context

00:05:32,282 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.web.deployment.default-host./SpringMVCreName" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./SpringMVCreName: JBAS018040: Failed to start context"}}}}

我找到了解决这个问题的方法:JBOSS 7 - Spring ContextLoaderListener ClassNotFoundException

这很奇怪,因为..

理论上这个问题已经解决了,但是昨天我在同一台服务器上开发了同样的应用程序,使用同样的设置,并且使用 maven 获取了同样的 jar,没有任何异常。

我想问如何在没有复制.jar文件的情况下解决问题。以及如何在没有手动(显式)用户干预的情况下自动执行此操作。

我只想做:

  • 创建项目
  • 使用 m2e 解决依赖关系
  • jboss并在使用时部署run
4

1 回答 1

1

您需要调查 java 类路径。当您的应用程序请求它们时,这些类必须可供类加载器加载。

通常对于 Web 应用程序,这意味着需要将包含类的 jar 打包到 WAR 的 /WEB-INF/lib 目录中。

使用 Maven,您应该使用包装类型war,而不是jar。然后maven的war插件(即http://maven.apache.org/plugins/maven-war-plugin/usage.html)会自动将所有依赖打包到war的lib文件夹中。

要使用 m2e 解决依赖关系,您应该

  • 确保项目使用 maven 从命令行编译和打包
  • 从eclipse中删除项目(不要删除文件)
  • 删除 Eclipse 元数据文件(即 .project、.classpath、.settings)
  • 打开日食
  • 导入 --> 导入现有的 Maven 项目 --> 选择你的项目

此时 m2e 将为您创建所有 eclipse 设置,包括动态类路径库。

于 2012-11-04T21:40:39.900 回答