Giesen Giesen wrote to log4j-users on 2006-07-10: I sporadically get the following error when my JSF app starts up. Anyone know what I can do? Would the 1.3 alpha version help? (I hate to use prerelease software) Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener java.lang.NullPointerException at org.apache.log4j.NDC.get(NDC.java:209) at org.apache.log4j.spi.LoggingEvent.getNDC(LoggingEvent.java:238) ---- Google searching for NDC.get did find other mentions of NPE being thrown at the same location. The stack trace is consistent with ht == null, however ht is expected to be initialized at class load and is not changed in the log4j code base, however the field is neither static or final so there is nothing preventing client code from changing its value. The log4j 1.3 implementation is substantially different. The committed patch checks whether ht != null before calling get() and should avoid the NPE, but would be nice to know the mechanism by which it got that way.
Patch committed in rev 427881. Waiting for feedback before marking as closed.
Hello, This problem does also occur in the MDC. I got the NullPointerException in NDC.get() as mentioned here and now in the MDC.get(). I think both are related to each other, so that's why I added this comment here. The exceptions are raised in my case, when I trigger a reload of a Tomcat context which uses Log4j as the logging system. Tomcat reloads the context and then: - before Log4j 1.2.14: NullPointerException at NDC.get (as mentioned here) - now: NullPointerException at MDC.get(). There propably the tlm==null. Can this be fixed too with a "not-null-check" in the next release of Log4j as was done with NDC.get()? Thanks
Reopening so Steven's comment gets noticed.
Split off MDC issue as bug 43181 since 40159 was reported as resolved in log4j 1.2.14 release notes. MDC fix committed in rev 568278.