使用jar库自动部署应用程序

时间:2012-11-04 21:27:30

标签: java eclipse maven spring-mvc jboss

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

    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

这很奇怪,因为......

Theroetical这个问题已被克服,但是,昨天我在同一台服务器上使用相同的设置开发了相同的应用程序,并使用maven获取同一个jar,没有任何exeptions。

我想问一下如何在没有copy-pase .jar文件的情况下解决问题。如果没有手动(明确)用户干预,这是如何自动完成的。

我只想这样做:

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

1 个答案:

答案 0 :(得分: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)
  • 打开日食
  • import - >导入现有的maven项目 - >选择你的项目

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