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: [classloading] How to use URLClassLoader within a servlet
Date Fri, 13 Dec 2002 03:16:27 GMT


On Thu, 12 Dec 2002, Ola Berg wrote:

> Date: Thu, 12 Dec 2002 12:19:35 +0100
> From: Ola Berg <ola.berg@ports.se>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> Subject: Re: [classloading] How to use URLClassLoader within a servlet
>
> >Or you could try to isolate the problem with an example and post
> >that to the list.
>
> The problem can be stated as
>
> ---8<---
>
> URL[] urls = new URL[]{ new URL("http://www.myserver.com/jars/myapi-1.2.jar") };
> URLClassLoader cl = new URLClassLoader( urls); //have tried different parents
>
> //here it hangs
> Class c = cl.loadClass( "nu.viggo.my.MyClass");
>
> --->8---
>
> Above snippet works in standalone app, but not in servlet.
>
> Tested with several kinds of URLs (class file directories, jarfiles, http, ftp) same
result.
>
> Any clues? Craig? Anyone?
>
> /O
>

When I battle with class loaders, I usually lose too :-).

However, If you want to use a remote JAR file in a class loader, shouldn't
the syntax of your URL match that defined in the Javadocs for
JarURLConnection?

Craig


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message