commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Perez <>
Subject Re: Commons logging and memory leaks
Date Wed, 18 May 2005 10:20:02 GMT
Hi Simon,

Thanks for your answer.
See my comments below....

Simon Kitching wrote:

>Firstly, I presume you mean commons-logging-1.0.5-alpha1? Note that this
>really is rather experimental; I presume jetty didn't come with this
>version of commons-logging?
You're right, I have changed the commons-logging version to the latest one.
Now I have reverted to commons-logging-1.0.2

>There are some cases which the weak-reference stuff cannot handle. And
>even the weak-reference stuff works, commons logging cleans up but the
>underlying logging library may not.

>I suggest registering a ServletContextListener. Declare a <listener>
>element in the web.xml file, with a nested <listener-class> element
>containing the fully qualified classname of a logging-cleanup class. In
>the contextDestroyed method of that class do this:
> * LogFactory.release(
>     Thread.currentThread().getContextClassLoader())
> * somehow cleaning up the underlying logging library if needed.
>If that doesn't help, let me know and we can look into it a bit
 From my code I call LogFactory.releaseAll() after removing the old web 
app context, and no luck :-(
Should my webapp use another copy of commons-logging.jar?


Another issue:

I have noticed a strange class loading behaviour new to the latest 
commons-logging releases.

Here is the logging jars I use in my app:

jars used by the web server (Jetty):

    * commons-logging.jar and
    * log4j.jar

jars used by the webapp:

    *    logkit.jar

    My web app uses Cocoon which uses Avalon LogKit, and makes me 
include logkit.jar, even though logging is redirected to log4j. 
    Some other classes use directly commons-logging

With commons-logging-1.0.4 and 1.05 alpha1, I have to make logkit.jar 
available to Jetty, otherwise commons-loggings throws a 
ClassNotFoundException, because it cannot find

org/apache/log/Hierarchy.  I wonder why it tries to load LogKit if Log4j is already available?

F 18 12:08:54 <main> [fcc.ima.servidor2.ServidorIma] Error al iniciar 

	at org.mortbay.util.Resource.newResource(
	at org.mortbay.util.Resource.newSystemResource(
	at org.mortbay.jetty.servlet.XMLConfiguration.configureDefaults(
	at org.mortbay.jetty.servlet.WebApplicationContext.configureDefaults(
	at org.mortbay.jetty.servlet.WebApplicationContext.doStart(
	at org.mortbay.util.Container.start(
	at org.mortbay.http.HttpServer.doStart(
	at org.mortbay.util.Container.start(
	at fcc.ima.servidor2.ServidorIma.main(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.mortbay.start.Main.invokeMain(
	at org.mortbay.start.Main.start(
	at org.mortbay.start.Main.main(
	at fcc.ima.servidor.Inicializacion.main(
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NoClassDefFoundError:
org/apache/log/Hierarchy (Caused by java.lang.NoClassDefFoundError: org/apache/log/Hierarchy)
	at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(
	at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(
	at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(
	at org.apache.commons.logging.LogFactory.getLog(
	at org.mortbay.util.JarResource.<clinit>(
	... 17 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log/Hierarchy
	at org.apache.commons.logging.impl.LogKitLogger.getLogger(
	at org.apache.commons.logging.impl.LogKitLogger.<init>(
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
	at java.lang.reflect.Constructor.newInstance(
	at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(
	... 21 more

On the other side, commons-logging-1.02 works ok.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message