标签:
由于原来项目与本地项目的环境不一致问题,误将Maven Dependencies 删除,重新update项目后未将jar导入tomcat,部署报错:
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/log4j/Logger; at java.lang.Class.getDeclaredFields0(Native Method) at java.lang.Class.privateGetDeclaredFields(Class.java:2436) at java.lang.Class.getDeclaredFields(Class.java:1806) at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106) at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:256) at org.apache.catalina.startup.WebAnnotationSet.loadApplicationFilterAnnotations(WebAnnotationSet.java:105) at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:64) at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:334) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:774) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5080) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 10 more Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167) ... 24 more
解决方法如下:
右键项目,properties,Deployment Assembly:
发现没有Maven Dependencies项,点击Add,出现如下界:
点击Java Build Path Entris 会出现Maven Dependencies选项,添加进来即可。
再次运行项目,问题解决。
总结:Maven Dependencies里面包含整个项目所需的jar包,部署到容器中时,必须将这些包,放到WEB-INF/lib 目录下。
标签:
原文地址:http://my.oschina.net/u/2245926/blog/514802