Tomcat& Spring Web - 找不到异常org.springframework.web.context.ContextLoaderListener [英] Tomcat & Spring Web - Class Not Found Exception org.springframework.web.context.ContextLoaderListener

查看:106
本文介绍了Tomcat& Spring Web - 找不到异常org.springframework.web.context.ContextLoaderListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试通过Eclipse启动Tomcat时,我得到以下异常(通过右键单击Project,Run As - > Run on Server)。

  SEVERE:配置org.springframework.web.context.ContextLoaderListener的应用程序侦听器时出错错误
java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener
在org.apache .catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
在org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
在org.apache.catalina.core .DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
在org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
在org.apache.catalina.core.DefaultInstanceManager.newInstance (DefaultInstanceManager.java:118)
在org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660)
在org.apache.cata lina.core.StandardContext $ 1.call(StandardContext.java:5226)
在org.apache.catalina.core.StandardContext $ 1.call(StandardContext.java:5221)
在java.util.concurrent。 FutureTask $ Sync.innerRun(FutureTask.java:303)
在java.util.concurrent.FutureTask.run(FutureTask.java:138)
在java.util.concurrent.ThreadPoolExecutor $ Worker.runTask( ThreadPoolExecutor.java:886)
在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:908)
在java.lang.Thread.run(Thread.java:662)
2011年6月12日8:46:11 org.apache.catalina.core.StandardContext listenerStart

我使用Maven(m2eclipse)构建我的项目。我已经添加了必要的依赖关系到Spring库,我可以在最后的工件(包含该类)的lib目录中看到spring-web.jar文件。当我将应用程序部署到IDE之外时,它的工作正常。



任何关于为什么会发生这种情况的指针将被高度赞赏。

解决方案

我在几天前面临同样的问题,在Eclipse Indigo上使用m2eclipse(不通过m2eclipse-extras可以使用WTP集成)。我创建了一个Maven Web模块,并手动添加了动态Web模块面。当我将它部署在Eclipse WST Tomcat Server上时,似乎我的Maven依赖关系在项目发布到该服务器时没有被推送到服务器。



解决方案很简单。右键单击项目资源管理器中的Web项目 - >选择属性。在项目属性下,选择部署程序集。



部署程序集属性页面显示了将Eclipse作为组装工件发布到服务器的内容。你需要告诉Eclipse你想要所有的Maven依赖关系也被发布。



要做到这一点,点击添加按钮,然后选择Java Build Path Entries 。单击下一步并选择Maven依赖关系。这将在Eclipse将项目发布到WST服务器时将Maven依赖JAR文件发布到lib文件夹。



此方法适用于我。


I get the following exception when I try to start Tomcat through Eclipse (via right click on Project, Run As -> Run on Server).

SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Jun 12, 2011 8:46:11 PM org.apache.catalina.core.StandardContext listenerStart

I am building my project using Maven (m2eclipse). I have added the necessary dependencies to Spring libraries, and I can see the spring-web.jar file in the lib directory of the final artifact (which contains the class). When I deploy the application outside of IDE, it works fine.

Any pointers as to why this happens would be highly appreciated.

解决方案

I faced the same problem few days ago with m2eclipse (without WTP integration add on available via m2eclipse-extras) on Eclipse Indigo. I created a Maven Web Module and manually added the Dynamic Web Module facet to it. When I deployed it on Eclipse WST Tomcat Server, it appeared that my Maven dependencies are not getting pushed to the server when the project is published to it.

The solution was simple. Right Click on your web project in Project Explorer -> select 'Properties'. Under project properties, select 'Deployment Assembly'.

The Deployment Assembly property page shows the content that will be published as a assembled artifact by Eclipse to the server. You need to tell Eclipse that you want all your Maven dependencies to be published too.

To do that, click 'Add' button, then select 'Java Build Path Entries'. Click Next and select Maven Dependencies. This will publish the Maven dependency JAR files to the lib folder when Eclipse publishes your project to WST server.

This approach worked for me.

这篇关于Tomcat& Spring Web - 找不到异常org.springframework.web.context.ContextLoaderListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆