Search code examples
log4jglassfish-3

Web application using log4j logs tons of severe error messages


I'm written an application which uses a library (Jabber stream objects) which internally uses log4j. When I deploy the application, there are no errors. However after some time, I could see lots of error message which look like this:

[#|2013-02-26T12:48:56.147+0000|SEVERE|oracle-glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=365;_ThreadName=SelectWorker 1;|java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [org.apache.log4j.spi.NOPLoggerRepository], because it has not yet been started, or was already stopped
        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1401)
        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
        at org.apache.log4j.LogManager.getLoggerRepository(LogManager.java:197)
        at org.apache.log4j.LogManager.getLogger(LogManager.java:228)
        at org.apache.log4j.Logger.getLogger(Logger.java:117)

I have log4j.jar inside the WEB-INF/lib directory of my application, along with the external library (JSO.jar)

The issue [1] looked similar, but doesn't seem to be the same.

[1] Web service is not working on GlassFish


Solution

  • I've found that this happens when I redeploy a Servlet and went away when I overridden destroy() for my Servlet and did some cleanup there.