On Sun, 11 Nov 2001, Mike Bremford wrote:

> Date: Sun, 11 Nov 2001 02:01:39 +0100
> From: Mike Bremford <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> 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:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to