tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew McDowall" <andy.mcdow...@edina.co.uk>
Subject WebappClassLoader delegates to SystemClassLoader, not CustomClassLoader
Date Fri, 14 Apr 2006 11:06:05 GMT
Hi,

I'm running into ClassLoader problems when using a custom ClassLoader
with an embedded Tomcat.  The problem, as I understand it, is arising
due to multiple versions of log4j being loaded by different ClassLoaders
resulting in ClassCastExceptions or expected interfaces not being
implemented.

In my main application's libraries I have log4j.jar - this is loaded by
a URLClassLoader, while in my WebApp's libraries I have a different
log4j.jar which is loaded by Tomcat's WebAppClassLoader.  Within my main
application I have an embedded Tomcat which is also loaded using the
URLClassLoader, thus Tomcat expects to use log4j classes that are bound
to the URLClassLoader, unfortunately the WebAppClassLoader does not
appear to be searching the URLClassLoader and instead loads log4j from
its own libraries.

As far as I can tell, the search order for the WebAppClassLoader never
actually delegates up beyond the Common-classLoader, instead it skips
straight to the SystemClassLoader avoiding my URLClassLoader.  I should
add that I have successfully implemented a 'hack' to my system which
uses the SystemClassLoader and have not encountered the same problems -
since when the WebAppClassLoader interrogates the SystemClassLoader the
expected version of log4j would be loaded.

Does anybody know of a way to get round this?  I'd assume that setting
my URLClassLoader to be the parent of the Common-ClassLoader would work
but I can't seem to find any documentation on how to achieve this.
Failing that is there a way to specify that Tomcat uses a subclass of
WebAppClassLoader (which I could write)?

 

Thanks in advance.

Andy McDowall.



--- Disclaimer ---

Unless otherwise agreed expressly in writing by a Director of Edina Software, this communication
is to be treated as confidential and the information in it may not be used or disclosed except
for the purpose for which it has been sent. If you have reason to believe that you are not
the intended recipient of this communication, please contact the sender immediately. 

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message