tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wade Chandler <>
Subject Re: Classloading issue
Date Thu, 09 Dec 2004 21:30:41 GMT
Yu, John wrote:
> Hi,
> I'm using Struts plugin, however, I think the issue mostly related to Tomcat
> ClassLoading.
> I have a class (in a jar) under WEB-INF/lib, which loads properties from 
> a file located under WEB-INF/classes. 
>      ClassLoader cl = getClass().getClassLoader();
>      InputStream stream = cl.getResourceAsStream("");
> I have tried different versions of path, with the results I couldn't totally
> explain:
> 1. "": not work
> 2. "WEB-INF/classes/": work
> 3. "/WEB-INF/classes/": not work
> 4. "/": not work
> Also, I'm using Tomcat 4.0.6 (NB3.5.1). Does anyone have an answer
> for this? Is "/" bad? It may apply to Tomcat 5 as well, isn't it?
> Regards,
> John
> The contents of this e-mail are intended for the named addressee only. It
> contains information that may be confidential. Unless you are the named
> addressee or an authorized designee, you may not copy or use it, or disclose
> it to anyone else. If you received it in error please notify us immediately
> and then destroy it. 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Me and another gentleman had this conversation just a little while 
ago...well one similar to it.  I always have a package which I put my 
files in.  I never have a problem doing that.  I always use 
Class.class.getResourceAsStream and getResource (should be roughly the 
same...usage is a little different).  I have a web app that has multiple 
installations on the same server and they always find their files.  But, 
I always use a package so I can access the files that way.  I quit using 
an empty package for everything when I started having goofy problems 
with different app servers.  I run into the same thing on Oracle 9iAS once.


Are very different when you are using ClassLoader.getResource(AsStream), 
and the same thing applies to Class.getResource(AsString)...see java 
docs.  Again, I never have a problem, and I load property files from 
under the classes directory all the time.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message