org.springframework.web.context.ContextLoaderListener(抛出java.lang.ClassNotFoundException)

时间:2013-12-10 06:51:08

标签: java eclipse spring-mvc jar jboss

  • 我正在使用JBoss 7.1
  • 的Eclipse 我有以下Jar文件(commons-dbcp.jar,commons-logging.jar,commons-pool.jar,jstl.jar,log4j-1.2.15.jar,mysql-connector-java-5.1.6-bin。罐子,的spring.jar,弹簧webmvc.jar,standard.jar)

当我尝试调试我的项目时,我收到以下错误

22:12:07,196 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/OnlinemployeeDB]] (MSC service thread 1-2) Error configuring application listener of class org.springframework.web.context.ContextLoaderListener: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener from [Module "deployment.OnlinemployeeDB.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(Unknown Source) [rt.jar:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_25]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_25]

22:12:07,216 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/OnlinemployeeDB]] (MSC service thread 1-2) Skipped installing application listeners due to previous error(s)
22:12:07,218 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-2) Error listenerStart
22:12:07,219 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-2) Context [/OnlinemployeeDB] startup failed due to previous errors
22:12:07,222 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.web.deployment.default-host./OnlinemployeeDB: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./OnlinemployeeDB: 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(Unknown Source) [rt.jar:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_25]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_25]

提前谢谢。

4 个答案:

答案 0 :(得分:13)

试试这个。

  1. 右键点击项目名称 - >点击属性
  2. 转到部署程序集
  3. 点击添加 - > Java构建路径条目 - >下一步
  4. 选择Maven依赖关系 - >完成 - >申请 - >行
  5. 清理项目和服务器。重启服务器
  6. 检查控制台。现在不应生成ContextLoaderListener异常。

答案 1 :(得分:1)

它表明您错过了一些jar文件。 我猜其中一个spring jar文件没有包装你的war文件,或者它可能不存在于目标应用程序服务器中, 您是否手动部署应用程序war文件? BTW您正在使用哪个版本的Spring?

答案 2 :(得分:1)

您缺少来自运行时类路径的org.springframework.web.context.ContextLoaderListener,位于spring-web-VERSION.jar中。如果它们在您的构建路径中无法找到运行时,则无效。您需要将.jars与.war库包装起来才能找到它们。

答案 3 :(得分:0)

配置应用程序时,您将成为以下其中一项

  • 缺少Jars

    here

  • 下载最新的Spring MVC 3.2.5 RELEASE jar
  • 将Jar文件添加到构建路径

    将下载的jar文件添加到项目构建路径中。阅读这篇文章link1link2

希望这能解决您的问题。