今天敲完ssm框架,启动tomcat时报了这个错误。如图:
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:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:527)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:509)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:137)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4823)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBaseStartChild.call(ContainerBase.java:1559)atorg.apache.catalina.core.ContainerBase
StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTaskSync.innerRun(FutureTask.java:334)atjava.util.concurrent.FutureTask.run(FutureTask.java:166)atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)atjava.util.concurrent.ThreadPoolExecutor
Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Mar 25, 2017 9:30:56 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Error configuring application listener of class org.springframework.web.util.IntrospectorCleanupListener java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:527) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:509) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:137) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4823) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381) 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$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) Mar 25, 2017 9:30:56 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Skipped installing application listeners due to previous error(s) Mar 25, 2017 9:30:56 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart Mar 25, 2017 9:30:56 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/ssm] startup failed due to previous errors Mar 25, 2017 9:30:56 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Mar 25, 2017 9:30:56 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Mar 25, 2017 9:30:56 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 1677 ms
这个错误看上去是找不到jar包引起的,但是检查完jar包的引用之后,发现spring-web的jar包是已经引用了的,如果是这种情况的话,解决方法就是将所引用的所有jar包拷贝一份到发布路径的WEB-INF/lib文件夹下。
注意
需要注意的是,eclipse配置完tomcat之后,如果我们不做修改的话,tomcat默认是发布到.metadata\plugins\目录下的wtpwebapps。这个目录在我们的项目目录下。如果想要更改到tomcat的发布目录下的话,我们可以重新添加一个server,选择tomcat,但是不要add任何项目,然后双击tomcat,在这个界面上进行修改:
修改后如图
总结
jar包找不到有可能是因为发布的时候tomcat没有自动将jar包拷贝过去,此时就需要我们手动拷贝一下。
PS:新方法
最近发现了解决这个问题的新方法,在项目上右击-》properties->Deployment Assembly,接下来如图:
然后下一步下一步直到finish,这样,就可以将maven下的jar包发布到发布文件夹下了。