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.
From my code I call LogFactory.releaseAll() after removing the old web app context, and no luck :-(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
further.
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 servidor
java.lang.ExceptionInInitializerError
at org.mortbay.util.Resource.newResource(Resource.java:73)
at org.mortbay.util.Resource.newSystemResource(Resource.java:186)
at
org.mortbay.jetty.servlet.XMLConfiguration.configureDefaults(XMLConfiguration.java:151)
at
org.mortbay.jetty.servlet.WebApplicationContext.configureDefaults(WebApplicationContext.java:415)
at
org.mortbay.jetty.servlet.WebApplicationContext.doStart(WebApplicationContext.java:464)
at org.mortbay.util.Container.start(Container.java:72)
at org.mortbay.http.HttpServer.doStart(HttpServer.java:695)
at org.mortbay.util.Container.start(Container.java:72)
at fcc.ima.servidor2.ServidorIma.main(ServidorIma.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.mortbay.start.Main.invokeMain(Main.java:153)
at org.mortbay.start.Main.start(Main.java:483)
at org.mortbay.start.Main.main(Main.java:91)
at fcc.ima.servidor.Inicializacion.main(Inicializacion.java:34)
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(LogFactoryImpl.java:538)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.mortbay.util.JarResource.<clinit>(JarResource.java:33)
... 17 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log/Hierarchy
at
org.apache.commons.logging.impl.LogKitLogger.getLogger(LogKitLogger.java:77)
at
org.apache.commons.logging.impl.LogKitLogger.<init>(LogKitLogger.java:64)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 21 more
On the other side, commons-logging-1.02 works ok.
Regards David
