Oops,
That's right, you can read any file you want from WEB-INF/classes using
getResource() (which is probably what you are doing) -- that is implemented
correctly in AdaptiveClassLoader. If you want to find all resources of a
specified name (for example, you have a properties file of the same name at
the web-application level and the system level, and you want to concatenate
values from both places together), the ClassLoader class provides a
getResources() method. (This method in turn calls findResources which is
supposed to be implemented in all subclasses of ClassLoader, but isn't for
AdaptiveClassLoader)
I'm glad to know that fixed it.
David
Will England wrote:
> On Fri, 20 Jul 2001, David Haraburda wrote:
>
> > Have you tried using the Jdk12Interceptor? That fixed class loading
> > problems for me. In your server.xml do:
> >
> > <RequestInterceptor
> > className="org.apache.tomcat.request.Jdk12Interceptor"/>
>
> Got that, and it fixed the finding of my .conf files that I store in
> WEB-INF/classes. I can now read any text file I want from WEB-INF/classes
> from a servlet.
>
> > Note this will only fix the loading of CLASSES... if you have resources
> > in your WEB-INF/classes directory, such as .properties files, that the
> > ClassLoader is supposed to pick up, this will not happen. I submitted a
> > patch for this to the mailing list last night, but haven't heard
> > anything from a developer/committer yet.
>
> Odd. Worked well for me. As soon as the admin gets the box back up, I'll
> drop you a copy of my server.xml and the code I use to read a text file.
>
> > A good way to see what ClassLoader is being used is by sticking in a
> > System.out.println( "CL: " +
> > Thread.currentThread().getContextClassLoader().toString() );
> >
> > If it says com.sun.misc.something (I forget the package name), you are
> > using the System classloader... if it says AdaptiveClassLoader, you are
> > using the Tomcat one which knows about stuff in the WEB-INF directory.
>
> Nice tip - I'll try that!
>
> Will