It is the expected behavior because the class loader for
TOMCAT_HOME/lib can't know which context you are trying to load from.  You
really need to put your utility class into each webapp's class path
(WEB-INF\classes or WEB-INF\lib) if you want it to access the classpath for
a particular webapp.

        Randy

-----Original Message-----
From: Shinta Tjio [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 02, 2001 2:03 PM
To: '[EMAIL PROTECTED]'
Subject: Tomcat's class loader 


Hi, all, 
I have a servlet, ServletFoo, that calls a utility 
class that lives in a jar file under $TOMCAT_HOME/lib. 
This utility class calls the ResourceBundle.getBundle() 
on a resource bundle that lives in the servlet's home 
(i.e: $TOMCAT_HOME/webapps/SomeContext/WEB-INF/). 
What I found out was that ServletFoo was loaded by 
Tomcat's AdaptiveClassLoader. The utility class 
was loaded by the system's default class loader. 
And of course, that utility class called 
ResourceBundle.getBundle() it couldn't find the 
resouce file because it lived in the servlet's 
home and the system's default class loader doesn't 
have CLASSPATH pointing to that directory. 
I have been able to fix this by passing the servlet's 
class loader to the utility class, so that it passes 
it to the ResourceBundle.getBundle(). 
My question is, is this the expected behavior of 
Tomcat's class loader? Or is this a bug? 
thanks, 
shinta 

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

Reply via email to