tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: ClassLoader woes in Tomcat 4.01
Date Mon, 12 Nov 2001 05:52:53 GMT


On Sun, 11 Nov 2001, Mike Bremford wrote:

> Date: Sun, 11 Nov 2001 02:01:39 +0100
> From: Mike Bremford <tomcat@big.faceless.org>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: ClassLoader woes in Tomcat 4.01
>
> Hi all
>
> I'm trying to load a resource from a JAR which I have placed in
> $TOMCAT_HOME/lib, but I can't seem to be able to access it from Tomcat
> 4. Works fine from an Application or Tomcat 3.2
>
> The symptoms are when I call
> ClassLoader.getSystemResource("/path/to/myresource"), I get null. It is
> definately there. The JAR isn't signed, there's no other unusual stuff
> going on. I'm calling this from inside a Filter if it makes a
> difference.
>
> Any ideas? If it helps the URL returned when I try this from an
> application is "jar:file:/home/mike/blah/myapp.jar!/path/to/myresource"
>

If you call ClassLoader.getSystemResource(), you are asking for the
resource to be loaded from the *system* class loader, which is a parent of
the class loader that deals with $TOMCAT_HOME/lib.  It works in Tomcat 3.2
because the class loader architecture is different -- the system class
loader in 3.2 contains these JARs.  Use ClassLoader.getResource() instead,
and you will be much happier.


For more information on how class loaders are configured in Tomcat 4, see:

  http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html

>
> Cheers... Mike
>

Craig McClanahan


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message