Not enough info to give you a code sample (since with Embedded, you are controlling the ClassLoaders, and Tomcat isn't doing it's default common/server/shared thing). However, what you want is one of the following (depending on your CL requirements): engine.setParentClassLoader(myClassLoader); host.setParentClassLoader(myClassLoader); context.setParentClassLoader(myClassLoader);
If you are using JMX-embedding, this is currently only supported at the Context level in JMX (although reflection still works for the others). As you might guess, setting it on the Engine sets it for all Hosts that don't have an explicit setting, setting it on the Host sets it for all Contexts that don't have an explicit setting, and setting it on the Context sets it for the Context. "Andrew McDowall" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] 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 ______________________________________________________________________ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]