Question : log4j called after unloading

I'm getting this error while running log4j in glassfish and starting the application from netbeans 6.8

1:
2:
SEVERE: log4j:ERROR log4j called after unloading, see http://logging.apache.org/log4j/1.2/faq.html#unload.
SEVERE: java.lang.IllegalStateException: Class invariant violation


I've been reading everywhere trying to find a solution and I don't know what to do anymore. log4j functions fine, but while glassfish is starting up or redeploying an application it is showing this error message. I'm not sure that it will harm anything in the rest of the program since log4j is functioning fine, but first off I hate error messages and it makes reading the server logs much more difficult since this error message shows about 4 - 6 times while glassfish is starting.

Thanks for your help

Answer : log4j called after unloading

Yep - I am seeing destroying and unloading of classes there - which probably also get the log4j classes down (static methods, not used by anyone else or being forcebly unloaded) - which causes the class to look unloaded.  That's exactly the kind of log I expected to see.

and that explain why this is an error - the call is coming from the spring, not from log4j itself.

1.2.16 is new enough - so you cannot get any more logging out of it even if you try to go up in the versions.

PS: http://logging.apache.org/log4j/1.2/xref/org/apache/log4j/LogManager.html might actually be a better explanation than anything I can say - see how the method  getLoggerRepository works - this is what causes all these error messages.

technically you might want to see if the advices here: http://logging.apache.org/log4j/1.2/faq.html#unload are helping in your case - org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES could probably stop the spring from unloading the ones that do not need to be unloaded but I suspect that it is not this class that causes the issues here anyway but worth a check.

There might be a setting in glassfish or in spring (or in both) to get them to play nicely together - but the problem as it seems is that something that would have been logged as debug if it was called internally, is logged as error because it comes externally.

As these are static members and as I mentioned before the message is written, the offending element IS initialized properly, the log4j is again properly initialized and can be used.
Random Solutions  
 
programming4us programming4us