Why does log4j throw a NullPointerException or print a message about NOPLoggerRepository when shutting down or restarting under Tomcat or during a shutdown hook?
Tomcat will, by default, clear all static members when unloading classes, however this process can trigger initialization of classes which may then call a class that has been cleared resulting in a NullPointerException or some undesirable behavior. Bug 40212) describes the problem in detail and has a patch which at this writing has not been applied to Tomcat. Glassfish had a similar problem and accepted the patch. The following are recommended to avoid this problem: • Set the org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES system property to false. • Apply the patch from bug 40212 or upgrade to a version that has that patch applied. • Upgrade to log4j 1.2.16 or later to better defend against class loader attack or provide a better diagnostic message when it does occur. It is impossible for log4j to defend against all attacks on its internal state by a class loader. There is a limit to the defensive measures that will be incorporated. For more background, see bugs 4
Related Questions
- When trying to print reports, I get an error message "Cannot shift objects off sheet" or Cashflow Plan fails to hide columns in certain reports?
- When trying to print reports, I get an error message "Cannot shift objects off sheet" or Exl-Plan fails to hide columns in certain reports?
- What is the difference between throw exception and print error message?