16

I'm facing the following Exception:

Mar 26, 2012 1:20:34 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.  
Could not   load org.apache.log4j.spi.ThrowableInformation.  
The eventual following stack trace is caused by an error thrown for debugging purposes 
as well as to attempt to terminate the thread which caused the illegal access, and has  
no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1562)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:165)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.error(Category.java:322)
at com.abc.supervisionmanager.Monitoring.run(Monitoring.java:205)
at java.lang.Thread.run(Thread.java:662)
Exception in thread "Thread_Monitoring" java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation
at org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:165)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.error(Category.java:322)
at com.abc.supervisionmanager.Monitoring.run(Monitoring.java:205)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.spi.ThrowableInformation
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
... 5 more

I googled about this exception and found that most answers points that it is bug in tomcat 5.5 and it will be solved in version 5.5.28.

However I'm currently using tomcat 7.11 with log4j-1.2.16.jar I'm still facing the same issue.

Ali Abdel-Aziz
  • 275
  • 1
  • 4
  • 13
  • If you have sym-linked any of the folders in your web app, look here: http://stackoverflow.com/questions/22240776/symlinking-tomcat-8-directory-resources – GlenPeterson Oct 16 '14 at 20:12

4 Answers4

9

For me, the solution for this issue (tested with Openbravo 3.0MP11 and Tomcat 7.0.21) was:

  1. Remove the log4j-1.2.16.jar from WEB-INF/lib.
  2. Put the log4j jar inside Tomcat's lib directory. In Ubuntu 11.10 this would be /usr/share/tomcat7/lib

Note for my specific use case of Openbravo: This does solve the log4j issue, but then I ran into other issues.

Hendy Irawan
  • 20,498
  • 11
  • 103
  • 114
2

Sounds like it is a problem with your libraries. Are you sure that you have the Log4J jar-file in the WEB-INF/lib folder of your webapp?

Mathias Schwarz
  • 7,099
  • 23
  • 28
  • Yes I have **log4j-1.2.16.jar** under 'my-webapplication\WEB-INF\lib\' – Ali Abdel-Aziz Mar 26 '12 at 15:04
  • Having the same issue here in Weblogic. I was suspecting a conflict between weblogic's log4j library and my application's, but even using weblogic's prefer-application-packages section of the weblogic.xml didn't clear it up. I run into it when attempting to use Spring MVC. – Jason Mar 26 '12 at 17:31
  • I'm having the same issue, trying to run Openbravo 3.0MP11 under Tomcat 7.0.21. I tried adding log4j under /var/lib/tomcat7/shared, /var/lib/tomcat7/shared/lib, /usr/share/tomcat7/lib...... nothing works :( – Hendy Irawan Jun 25 '12 at 08:51
  • Openbravo also ships its own log4j under ./WEB-INF/lib/log4j-1.2.16.jar – Hendy Irawan Jun 25 '12 at 08:52
  • how does having multiple log4j jars cause it to not find a class, anybody know? – rogerdpack Aug 26 '13 at 16:21
0

How to solve it . For me:

  1. try {} catch() log4j exception throw.
  2. run tomcat again to find the real problem
  3. solve the real problem and delete try{} catch()

It is not problem for log4j and tomcat. It will throw exception because some of your code run error in webapp init. Maybe xml or config is error.

user918888
  • 151
  • 1
  • 7
0

I had this problem with a portlet (liferay 6.2 Tomcat bundle). I fixed it by deleting the deployment that caused the exception (in the tomcat webapps folder), cleaning and redeploying (with maven -- liferay:deploy) the portlet.

geco17
  • 5,152
  • 3
  • 21
  • 38