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。



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




2012-12-15 19:40:01 org.apache.catalina.core.AprLifecycleListener init
信息: 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\;.
2012-12-15 19:40:01 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:fanjf' did not find a matching property.
2012-12-15 19:40:01 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
2012-12-15 19:40:01 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8009"]
2012-12-15 19:40:01 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 930 ms
2012-12-15 19:40:01 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
2012-12-15 19:40:01 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.33
2012-12-15 19:40:02 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: 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
2012-12-15 19:40:02 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: 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
2012-12-15 19:40:04 org.apache.catalina.core.ApplicationContext log
信息: Set web app root system property: 'webName.root' = [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\fanjf\]
2012-12-15 19:40:04 org.apache.catalina.core.ApplicationContext log
信息: Initializing log4j from [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\fanjf\WEB-INF\log4j.properties]
2012-12-15 19:40:08 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
	at org.springframework.util.Log4jConfigurer.initLogging(Log4jConfigurer.java:106)
	at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:144)
	at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:47)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
	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(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.PropertyConfigurator
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
	... 13 more
21298225
2012-12-15 19:40:09 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2012-12-15 19:40:09 org.springframework.web.context.ContextLoader initWebApplicationContext
信息: Root WebApplicationContext: initialization started
2012-12-15 19:40:09 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: 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
2012-12-15 19:40:09 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/com/taobao/www/fanjf/config/applicationContext.xml]
2012-12-15 19:40:09 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/com/taobao/www/fanjf/config/applicationContext-services.xml]
2012-12-15 19:40:09 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@4d092447]: org.springframework.beans.factory.support.DefaultListableBeanFactory@15c313da
2012-12-15 19:40:09 org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
信息: Loading properties file from class path resource [jdbc.properties]
2012-12-15 19:40:09 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: 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
2012-12-15 19:40:09 org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
信息: Loaded JDBC driver: com.mysql.jdbc.Driver
2012-12-15 19:40:10 org.springframework.web.context.ContextLoader initWebApplicationContext
信息: Root WebApplicationContext: initialization completed in 1610 ms
2012-12-15 19:40:10 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
2012-12-15 19:40:10 org.apache.catalina.core.StandardContext startInternal
严重: Context [/fanjf] startup failed due to previous errors
2012-12-15 19:40:10 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2012-12-15 19:40:10 org.springframework.context.support.AbstractApplicationContext doClose
信息: 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
2012-12-15 19:40:10 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
信息: 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
2012-12-15 19:40:10 org.apache.catalina.core.ApplicationContext log
信息: Shutting down log4j
2012-12-15 19:40:10 org.apache.catalina.core.StandardContext listenerStop
严重: Exception sending context destroyed event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.NoClassDefFoundError: org/apache/log4j/LogManager
	at org.springframework.util.Log4jConfigurer.shutdownLogging(Log4jConfigurer.java:117)
	at org.springframework.web.util.Log4jWebConfigurer.shutdownLogging(Log4jWebConfigurer.java:170)
	at org.springframework.web.util.Log4jConfigListener.contextDestroyed(Log4jConfigListener.java:51)
	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4831)
	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
	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(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
	... 14 more
2012-12-15 19:40:10 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: 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.
2012-12-15 19:40:10 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
2012-12-15 19:40:10 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
2012-12-15 19:40:10 org.apache.catalina.startup.Catalina start
信息: Server startup in 9190 ms


解决办法:

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

http://m.blog.csdn.net/blog/thisisvoa/8299620

你可能感兴趣的:(Web,错误信息)