tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: weird tomcat5.0.30 behaviour with jar in WEB-INF/classes
Date Wed, 01 Dec 2004 14:47:12 GMT


>I use URLClassLoader to create class loaders that manage jars in WEB-
>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:
>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:
>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

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:
For additional commands, e-mail:

View raw message