java.lang.NoClassDefFoundError: org/apache/log4j/LogManager

新系统(Tomcat7 spring 2.5  struts2 2.3),配置spring的log4j日志,死活不能运行,导致项目在tomcat7中运行的时候一直提示错误,版本也更换了几次。

因为刚刚开始的时候担心是不是版本不兼容,后来发现不是这个问题,因为程序org.apache.log4j.PropertyConfigurator就进入不去了,提示source  not found。开始怀疑是不是web容器的问题,因为本地测试log4j是没有问题的。

提示source  not  found。



现在把错误贴出来给大家分享一下心得:




[html] view plain copy
  1. 2012-12-15 19:40:01 org.apache.catalina.core.AprLifecycleListener init  

  2. 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\jdk\jre6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Services\IPT\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;C:\SWTOOLS\ReadyApps;D:\jdk\bin;D:\jdk\jre\bin;C:\Program Files\TortoiseSVN\bin;D:\Program Files (x86)\MySQL\MySQL Server 5.0\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;.  

  3. 2012-12-15 19:40:01 org.apache.tomcat.util.digester.SetPropertiesRule begin  

  4. 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:fanjf' did not find a matching property.  

  5. 2012-12-15 19:40:01 org.apache.coyote.AbstractProtocol init  

  6. 信息: Initializing ProtocolHandler ["http-bio-8080"]  

  7. 2012-12-15 19:40:01 org.apache.coyote.AbstractProtocol init  

  8. 信息: Initializing ProtocolHandler ["ajp-bio-8009"]  

  9. 2012-12-15 19:40:01 org.apache.catalina.startup.Catalina load  

  10. 信息: Initialization processed in 930 ms  

  11. 2012-12-15 19:40:01 org.apache.catalina.core.StandardService startInternal  

  12. 信息: Starting service Catalina  

  13. 2012-12-15 19:40:01 org.apache.catalina.core.StandardEngine startInternal  

  14. 信息: Starting Servlet Engine: Apache Tomcat/7.0.33  

  15. 2012-12-15 19:40:02 org.apache.catalina.loader.WebappClassLoader validateJarFile  

  16. 信息: validateJarFile(D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\fanjf\WEB-INF\lib\servlet-4.1.36.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class  

  17. 2012-12-15 19:40:02 org.apache.catalina.loader.WebappClassLoader validateJarFile  

  18. 信息: validateJarFile(D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\fanjf\WEB-INF\lib\servlet-api-5.0.16.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class  

  19. 2012-12-15 19:40:04 org.apache.catalina.core.ApplicationContext log  

  20. 信息: Set web app root system property: 'webName.root' = [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\fanjf\]  

  21. 2012-12-15 19:40:04 org.apache.catalina.core.ApplicationContext log  

  22. 信息: Initializing log4j from [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\fanjf\WEB-INF\log4j.properties]  

  23. 2012-12-15 19:40:08 org.apache.catalina.core.StandardContext listenerStart  

  24. 严重: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener  

  25. java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator  

  26.    at org.springframework.util.Log4jConfigurer.initLogging(Log4jConfigurer.java:106)  

  27.    at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:144)  

  28.    at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:47)  

  29.    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)  

  30.    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)  

  31.    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)  

  32.    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)  

  33.    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)  

  34.    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)  

  35.    at java.util.concurrent.FutureTask.run(Unknown Source)  

  36.    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)  

  37.    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  

  38.    at java.lang.Thread.run(Unknown Source)  

  39. Caused by: java.lang.ClassNotFoundException: org.apache.log4j.PropertyConfigurator  

  40.    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)  

  41.    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)  

  42.    ... 13 more  

  43. 21298225  

  44. 2012-12-15 19:40:09 org.apache.catalina.core.ApplicationContext log  

  45. 信息: Initializing Spring root WebApplicationContext  

  46. 2012-12-15 19:40:09 org.springframework.web.context.ContextLoader initWebApplicationContext  

  47. 信息: Root WebApplicationContext: initialization started  

  48. 2012-12-15 19:40:09 org.springframework.context.support.AbstractApplicationContext prepareRefresh  

  49. 信息: Refreshing org.springframework.web.context.support.XmlWebApplicationContext@4d092447: display name [Root WebApplicationContext]; startup date [Sat Dec 15 19:40:09 CST 2012]; root of context hierarchy  

  50. 2012-12-15 19:40:09 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions  

  51. 信息: Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/com/taobao/www/fanjf/config/applicationContext.xml]  

  52. 2012-12-15 19:40:09 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions  

  53. 信息: Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/com/taobao/www/fanjf/config/applicationContext-services.xml]  

  54. 2012-12-15 19:40:09 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory  

  55. 信息: Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@4d092447]: org.springframework.beans.factory.support.DefaultListableBeanFactory@15c313da  

  56. 2012-12-15 19:40:09 org.springframework.core.io.support.PropertiesLoaderSupport loadProperties  

  57. 信息: Loading properties file from class path resource [jdbc.properties]  

  58. 2012-12-15 19:40:09 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons  

  59. 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@15c313da: defining beans [config,dataSource,sqlMapClient,sbookDAO,itemcatDAO,userDAO,fanjfReportMemeberDAO,userInviteDAO,sbookServices,itemcatServices,userServices,userInviteServices,fanjfReportMemeberServices,sbookAction,itemcatAction,userAction,userInviteAction,statusAction,DisplayPayedAction,reportAction,toLogoutAction,searchAction,initAction,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,servicesPointcut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,txAdvice]; root of factory hierarchy  

  60. 2012-12-15 19:40:09 org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName  

  61. 信息: Loaded JDBC driver: com.mysql.jdbc.Driver  

  62. 2012-12-15 19:40:10 org.springframework.web.context.ContextLoader initWebApplicationContext  

  63. 信息: Root WebApplicationContext: initialization completed in 1610 ms  

  64. 2012-12-15 19:40:10 org.apache.catalina.core.StandardContext startInternal  

  65. 严重: Error listenerStart  

  66. 2012-12-15 19:40:10 org.apache.catalina.core.StandardContext startInternal  

  67. 严重: Context [/fanjf] startup failed due to previous errors  

  68. 2012-12-15 19:40:10 org.apache.catalina.core.ApplicationContext log  

  69. 信息: Closing Spring root WebApplicationContext  

  70. 2012-12-15 19:40:10 org.springframework.context.support.AbstractApplicationContext doClose  

  71. 信息: Closing org.springframework.web.context.support.XmlWebApplicationContext@4d092447: display name [Root WebApplicationContext]; startup date [Sat Dec 15 19:40:09 CST 2012]; root of context hierarchy  

  72. 2012-12-15 19:40:10 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons  

  73. 信息: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@15c313da: defining beans [config,dataSource,sqlMapClient,sbookDAO,itemcatDAO,userDAO,fanjfReportMemeberDAO,userInviteDAO,sbookServices,itemcatServices,userServices,userInviteServices,fanjfReportMemeberServices,sbookAction,itemcatAction,userAction,userInviteAction,statusAction,DisplayPayedAction,reportAction,toLogoutAction,searchAction,initAction,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,servicesPointcut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,txAdvice]; root of factory hierarchy  

  74. 2012-12-15 19:40:10 org.apache.catalina.core.ApplicationContext log  

  75. 信息: Shutting down log4j  

  76. 2012-12-15 19:40:10 org.apache.catalina.core.StandardContext listenerStop  

  77. 严重: Exception sending context destroyed event to listener instance of class org.springframework.web.util.Log4jConfigListener  

  78. java.lang.NoClassDefFoundError: org/apache/log4j/LogManager  

  79.    at org.springframework.util.Log4jConfigurer.shutdownLogging(Log4jConfigurer.java:117)  

  80.    at org.springframework.web.util.Log4jWebConfigurer.shutdownLogging(Log4jWebConfigurer.java:170)  

  81.    at org.springframework.web.util.Log4jConfigListener.contextDestroyed(Log4jConfigListener.java:51)  

  82.    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4831)  

  83.    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)  

  84.    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)  

  85.    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)  

  86.    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)  

  87.    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)  

  88.    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)  

  89.    at java.util.concurrent.FutureTask.run(Unknown Source)  

  90.    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)  

  91.    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  

  92.    at java.lang.Thread.run(Unknown Source)  

  93. Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager  

  94.    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)  

  95.    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)  

  96.    ... 14 more  

  97. 2012-12-15 19:40:10 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc  

  98. 严重: The web application [/fanjf] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.  

  99. 2012-12-15 19:40:10 org.apache.coyote.AbstractProtocol start  

  100. 信息: Starting ProtocolHandler ["http-bio-8080"]  

  101. 2012-12-15 19:40:10 org.apache.coyote.AbstractProtocol start  

  102. 信息: Starting ProtocolHandler ["ajp-bio-8009"]  

  103. 2012-12-15 19:40:10 org.apache.catalina.startup.Catalina start  

  104. 信息: Server startup in 9190 ms  


解决办法:




直接把log4j-1.2.15.jar   slf4j-api-1.5.0.jar    slf4j-log4j12-1.5.0.jar  拷贝到tomcat根目录的lib下面,问题解决。


你可能感兴趣的:(spring,struts2,tomcat7,source,不能启动,found,2.5,not)