java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoadListener

java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoadListener,java,eclipse,spring,tomcat7,classnotfoundexception,Java,Eclipse,Spring,Tomcat7,Classnotfoundexception,我已经为这个问题挣扎了几天了(这就是为什么我要提供GitHub链接)。 以下是堆栈跟踪: SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoadListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoadListener at

我已经为这个问题挣扎了几天了(这就是为什么我要提供GitHub链接)。 以下是堆栈跟踪:

    SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoadListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoadListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:142)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4854)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
我只想指出,我使用Tomcat7,并在Eclipse中从Servers选项卡运行服务器

我在网上读到了关于它的一切。提供的最常见解决方案是:

转到项目属性->部署程序集,单击添加, 选择Java构建路径条目并将Maven依赖项添加到 Web部署程序集。“

它对我不起作用,就像我迄今为止在互联网上看到的其他解决方案一样。我绝望了

我正在为我的项目提供GitHub链接: 我已经尝试将其导出到另一台计算机,但在另一台计算机上运行时仍会出现相同的错误

报告说: 在部署环境中,只需确保您的服务器类路径包含SpringJAR库(例如Spring-2.5.6.jar)

对于Spring3,ContextLoaderListener被移动到spring-web.jar,您可以从Maven中央存储库获取库


org.springframework
弹簧网
3.0.5.1发布

您确定您的构建路径(在eclipse中)实际上包含所有依赖项(在本例中特别是SpringWeb和SpringWebMVC)吗? 如果您使用
mvn clean install
构建一个*.war文件,如果您将其解包,库可能会包含在其中

但是,这与Eclipse不同。因此,我建议在您的目录中运行
mvn clean install eclipse:clean eclipse:eclipse
。然后在Eclipse中刷新项目并将其清理(项目->清理)

若要查看库是否正确部署,请双击服务器并转到此位置(在工作区文件夹中):

并检查
WEB-INF/lib
文件夹中的依赖项(*.jar文件)

一般来说,这为我解决了问题。你应该:

  • 在Eclipse中关闭服务器
  • 右键单击->清理->清理Tomcat工作目录
  • 运行上面的命令
  • 启动服务器

引导Spring根上下文的正确侦听器类是ContextLoaderListener,而不是ContextLoadListener!因此,在web.xml中应该是:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

org.springframework.web.context.ContextLoaderListener

有时候清理tomcat可以解决这个问题。您在项目库中看到“Maven Dependencies”文件夹了吗?@SRy不幸的是,我已经看到了。我在我的项目库中看到了Maven依赖项。你能在这里发布你的项目结构吗?@SRy你来找我你的部署程序集看起来有问题。Maven项目结构应该是
src/main/java
。检查您的部署程序集,如下所示。并从类路径中删除Tomcat7库。是否要将spring-2.5.6.jar(或spring-web-4.1.5.RELEASE.jar)复制到C:\something\Tomcat7\lib目录?如果没有,我在哪里可以找到服务器类路径?但是如果OP确实使用了POM.xml,无论他从
github
链接复制了什么,他都不需要做任何事情。我怀疑OP缺少一些配置。我制作了一个.war文件并将其解压缩以检查库是否存在。一切都很好。我已经清理了目录,没有帮忙;(我检查了库是否存在:C:\something\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\beer blog hiccup\WEB-INF\lib,它们都已经存在了。@SchakaI`我现在很尴尬,很抱歉给您带来不便!谢谢您的回答。