Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 7 - java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation

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.

like image 587
Ali Abdel-Aziz Avatar asked Mar 26 '12 12:03

Ali Abdel-Aziz


People also ask

How do you fix No Class Def Found error?

lang. NoClassDefFoundError, which means the Class Loader file responsible for dynamically loading classes can not find the . class file. So to remove this error, you should set your classpath to the location where your Class Loader is present.

What is Log4j category?

Logger is a subclass of Category, i.e. it extends Category. In other words, a logger is a category. Thus, all operations that can be performed on a category can be performed on a logger. Internally, whenever log4j is asked to produce a Category object, it will instead produce a Logger object.

What is Log4j API jar?

API for Apache Log4J, a highly configurable logging tool that focuses on performance and low garbage generation. It has a plugin architecture that makes it extensible and supports asynchronous logging based on LMAX Disruptor.


2 Answers

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.

like image 180
Hendy Irawan Avatar answered Oct 23 '22 13:10

Hendy Irawan


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?

like image 33
Mathias Schwarz Avatar answered Oct 23 '22 14:10

Mathias Schwarz