Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 51347 invoked from network); 15 Apr 2006 01:53:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Apr 2006 01:53:46 -0000 Received: (qmail 8371 invoked by uid 500); 15 Apr 2006 01:53:36 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 7354 invoked by uid 500); 15 Apr 2006 01:53:33 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 7342 invoked by uid 99); 15 Apr 2006 01:53:33 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Apr 2006 18:53:33 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jak-tomcat-user@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from [80.91.229.2] (HELO ciao.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Apr 2006 18:53:33 -0700 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FUZy9-0002kz-HR for users@tomcat.apache.org; Sat, 15 Apr 2006 03:53:01 +0200 Received: from pool-71-107-248-34.lsanca.dsl-w.verizon.net ([71.107.248.34]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 15 Apr 2006 03:53:01 +0200 Received: from wbarker by pool-71-107-248-34.lsanca.dsl-w.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 15 Apr 2006 03:53:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: users@tomcat.apache.org From: "Bill Barker" Subject: Re: WebappClassLoader delegates to SystemClassLoader, not CustomClassLoader Date: Fri, 14 Apr 2006 18:52:54 -0700 Lines: 71 Message-ID: References: X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pool-71-107-248-34.lsanca.dsl-w.verizon.net X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original Sender: news X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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" wrote in message news:F1CE4737D64A1D4ABAC71CB4ACD2D8EA018F2F07@salentino.edina.co.uk... 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: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org