You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Curt Arnold <ca...@apache.org> on 2009/01/02 03:27:02 UTC
Re: Strange NPEs after redeploy
You are most likely encountering a known Tomcat bug where unloaded
classes can be inadvertently used during static initialization of
other classes. There is a patch for Tomcat which has been integrated
into Glassfish, but there has been no action to integrate it into
Tomcat. If you can't apply the patch to Tomcat, you can disable the
buggy clear references code by setting a system property.
https://issues.apache.org/bugzilla/show_bug.cgi?id=41059
https://glassfish.dev.java.net/issues/show_bug.cgi?id=6637
It has been document in the FAQ for the upcoming log4j 1.2.16, but
that hasn't been posted to the site. Here is the content.
<faq id="unload">
<question>Why does log4j throw a NullPointerException or
print a message about NOPLoggerRepository
when shutting down or restarting under Tomcat or during
a shutdown
hook?</question>
<answer><p>Tomcat will, by default,
clear all static members when unloading classes.
Unfortunately, under certain circumstances
another class may attempt to call log4j after log4j
has had its private member variables cleared, resulting
in either
a NullPointerException (log4j 1.2.14 or earlier) or a
console
message (log4j 1.2.15 and later). The same type of issue
has been reported during various shutdown hooks (see bug
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=40212
">40212</a>)
but the mechanisms are not as well understood.</p>
<p>The following have been recommended to avoid this
problem:
<ol>
<li>Set the
org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES
system property to false.</li>
<li>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.</li>
<li>Use per-application copies of log4j, that is
remove log4j.jar from WEB-INF/lib.</li>
<li>Avoid calls to log4j from within class
initialization.</li>
<li>Upgrade to the latest version of the
framework that causing the problem.</li>
<li>Use EnhancedPatternLayout from the extras
companion when the NPE occurs
in a call of PatternLayout.</li>
</ol>
</p>
<p>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.</p>
<p>For more background, see bugs
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=40212
">40212</a>,
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=41939
">41939</a>,
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=43867
">43867</a>,
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=40159
">40159</a>,
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=43181
">43181</a>,
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=41316
">41316</a> and
<a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=37956
">37956</a>.
</p>
</answer>
</faq>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Strange NPEs after redeploy
Posted by Curt Arnold <ca...@apache.org>.
On Jan 2, 2009, at 12:04 PM, Jacob Kjome wrote:
> Hi Curt,
>
> What does the following mean?...
>
> On 1/1/2009 8:27 PM, Curt Arnold wrote:
>> <li>Use per-application copies of log4j, that is remove log4j.jar
>> from
>> WEB-INF/lib.</li>
>
I think I cut and pasted from suggestions on the mailing list. Tomcat
deployment issues are not my speciality. It would be really really
nice if Tomcat would actually fix this since it has been reported tons
of times and not just involving log4j and Glassfish is happy with our
patch.
Please fix, modify or remove as appropriate. Source is in src/site/
fml/faq.fml (or something like that)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Strange NPEs after redeploy
Posted by Jacob Kjome <ho...@visi.com>.
Hi Curt,
What does the following mean?...
On 1/1/2009 8:27 PM, Curt Arnold wrote:
> <li>Use per-application copies of log4j, that is remove log4j.jar from
> WEB-INF/lib.</li>
The first part says "use per-application copies of log4j" and then it says "that
is remove log4j.jar from WEB-INF/lib". From my point of view, those two sentence
fragments contradict one another. Adding log4j.jar to WEB-INF/lib *is* the
definition of using per-application copies of log4j. The only two other ways,
both involving putting log4j in a global classloader, would be to run only one
application per appserver or use repository selectors to provided each application
with its own logger repository.
I'm not entirely sure what the recommendation should be here? I guess I leave it
to you to correct.
Jake
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org