Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 77560 invoked from network); 9 Nov 2005 20:20:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Nov 2005 20:20:01 -0000 Received: (qmail 65207 invoked by uid 500); 9 Nov 2005 20:19:50 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 65167 invoked by uid 500); 9 Nov 2005 20:19:49 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 65156 invoked by uid 99); 9 Nov 2005 20:19:49 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Nov 2005 12:19:49 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [128.253.83.141] (HELO authusersmtp.mail.cornell.edu) (128.253.83.141) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Nov 2005 12:19:42 -0800 Received: from [128.253.57.77] (aeolus.cit.cornell.edu [128.253.57.77]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.13.1/8.12.10) with ESMTP id jA9KJS27023167 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 9 Nov 2005 15:19:28 -0500 (EST) Message-ID: <437259D4.1030206@cornell.edu> Date: Wed, 09 Nov 2005 15:19:32 -0500 From: Aaron Hamid User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: dev@tomcat.apache.org Subject: Subtlety in WebappClassLoader wrt to leading '/' Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi all, I have searched bugzilla, and the tc-users and tc-dev lists on MARC, as well as the source code, so hopefully this is vetted enough for this list (I have NOT posted a bug). It appears that WebappClassLoader (in at least versions 5.0.28 and 5.5.12 which I have looked at) will accept a leading slash '/' on the resource path parameter to the 'getResource*()' calls. This implicit support appears to be due to the File and URI/URL APIs it uses to resolve the resource. While it is intuitive to me to support a leading slash, Sun's application class loader behavior is different. Resource paths with leading slashes are not found. When the slash is removed they are found. I could not find any mention of these semantics in the standard ClassLoader (not Class, I am aware of how Class.getResource differs) documentation, however a quick Google search will confirm the notion that ClassLoader will not find resources with leading slashes (at least one old post on tomcat-dev: http://mail-archives.apache.org/mod_mbox/tomcat-dev/200108.mbox/%3C3B7854FF.2FA71171@apache.org%3E quote at bottom). I raise this issue because I just spent a lot of time debugging a problem where a certain resource WAS found in Tomcat, but was not found when running JUnit tests from Ant or from within Eclipse. Ultimately it was my fault for prepending a slash, but I wonder if it is worth either matching Sun's behavior, or documenting this somewhere (and again, I may have missed it). Aaron Hamid CIT/ATA Cornell University --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org