commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject [logging] diagnostics, RC failure in webapp
Date Sun, 16 Apr 2006 12:32:41 GMT

I've been able to reproduce the logging problem I reported earlier with
very little trouble. However I am unable to figure out *why* it's

To summarise: Class Log4JLogger is being loaded from a classloader; that
classloader can see file "Log4JLogger.class" fine as a resource.
Log4JLogge depends on org.apache.log4j.Category, but that is also
visible from the classloader. Yet Log4JLogger gets NoClassDefFound when
loaded. Very puzzling.

As you can see, while investigating this I found the need for some more
diagnostics so I've added them.

In particular, method createLogFromClass now uses
ClassLoader.getResource to get a URL for the logging adapter class it is
trying to load, and outputs the URL as a diagnostic. This is really
useful as it indicates which directory or jar the file is being loaded

To duplicate the problem:
 * install tomcat 5.5.15 (well, that's the version I'm using anyway)
 * create directory
 * place commons-logging-1.0.4.jar and log4j-1.2.12.jar in WEB-INF/lib
 * place a file in WEB-INF/classes, with:
 * overwrite ${tomcat.home}/bin/commons-logging-api.jar with the
 * export JAVA_OPTS="-Dorg.apache.commons.logging.\
 * start tomcat, look at ${tomcat.home}/logs/catalina.out

The (enhanced) logging clearly indicates that Log4JLogger is being
loaded from the WEB-INF/lib/commons-logging-1.0.4.jar file. However when
loadClass is called, a NoClassDefFound exception occurs whose message is
"org/apache/log4j/Category". However that class clearly *is* in the
log4j jarfile in the same lib directory. Log4j has no external
dependencies, so I can't see that Category could be missing any of *its*

As a test I wrote a simple stand-alone app that creates a, adds commons-logging-1.0.4 and log4j.1.12, and
uses reflection to load Log4JLogger. This works fine.

I've not tried any lib versions other than the ones above, eg

I'll try to find time to look into this again tomorrow, but if anyone
else wants to have a shot, please do so! I'm guessing I'm missing
something very obvious but I just can't see it. 

One thing I was trying to do (and failed) was to enable logging for
category "org.apache.catalina.loader", as the WebappClassLoader class in
there has some potentially useful logging. I tried tweaking
${tomcat.home}/conf/ but that didn't seem to have any



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message