Hi,

>I use URLClassLoader to create class loaders that manage jars in WEB-
>INF/classes
>In WEB-INF/classes I have many jars that are incompatible each other
>(they have different classes with the same name inside).

I comment on the actual problem below, but if you don't mind me asking:
why?  This is ugly ;)

>In the first case I tried the line:
>classLoader.getResource("pippo.txt")
>
>and correctly the returned URL was:
> file:/ ... /myapp/WEB-INF/classes/pippo.txt
>
>where "..." stands for $CATALINA_HOME
>while, trying to get the second file:
>classLoader.getResource("pippo.jar")
>
>tomcat returned the following url:
> file:/ ... /work/Catalina/localhost/myapp/loader/pippo.jar
>
>but the directory "... /work/Catalina/localhost/myapp/loader/" does
>not contain pippo.jar
>that is placed in  .../myapp/WEB-INF/classes/pippo.jar

The one in $CATALINA_HOME/work is an unmodified copy, so it should be
OK.  But there's a bigger point here (actually two):

- You cannot rely on a specific scheme (e.g. file:/) or format of the
resource URL returned by the classloader, but you can rely on the
classloader being able to find and resolve it.  Only the latter should
matter.  If you're relying on the former, change your design.

- What's you're doing is tricky at best.  Having multiple copies of te
same class in the same repository is not a good idea.  If you do
continue down this path, you should create a custom loader and replace
Tomcat's default webapp classloader with your own by registering yours
as the Loader element for your Context.

Yoav Shapira http://www.yoavshapira.com



This e-mail, including any attachments, is a confidential business 
communication, and may contain information that is confidential, proprietary 
and/or privileged.  This e-mail is intended only for the individual(s) to whom 
it is addressed, and may not be saved, copied, printed, disclosed or used by 
anyone else.  If you are not the(an) intended recipient, please immediately 
delete this e-mail from your computer system and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to