Yes, yes, I know what the docs say. The point is,
ClassLoader.getResource should be able to retrieve
anything in the current classpath, and WEB-INF/classes
*definitely* ought to be in the classpath - the very
same ClassLoader loads class files from it after all.
However, as I said, when running under Orion
(specifically, from JSPs - I haven't tested servlets),
it isn't. This is a significant bug as far as I'm
concerned.
In order to use ServletContext.getResource, you have
to have a reference to a ServletContext. And since
there is no global method to retrieve one, it is not
always possible to access it. In our application, the
majority of our classes don't have access to the
ServletContext, and since the app is entirely
JSP-driven, there is no convenient global place to put
a reference.
roger
--- Jason Smith <[EMAIL PROTECTED]> wrote:
>
> From the JDK 1.3 Javadoc for
> ClassLoader.getResource():
> This method will first search the parent class
> loader for the resource; if
> the parent is null the path of the class loader
> built-in to the virtual
> machine is searched. That failing, this method will
> call findResource to
> find the resource.
>
> From the Servlet 2.2 Javadoc for
> ServletContext.getResource();
> This method allows the servlet container to make a
> resource available to
> servlets from any source. Resources can be located
> on a local or remote file
> system, in a database, or in a .war file.
>
> Maybe try using the ServletContext.getResource()
> instead of the ClassLoader?
>
> > The ClassLoader.getResource* methods do not seem
> to
> > work properly in 1.4.5. I have been trying to use
> > these methods to load resources from my
> > WEB-INF/classes directory, and they fail every
> time.
> > After experimenting, I found out that these
> methods
> > expect to load resources from orion/lib.
> >
> > This seems broken. I would expect that each
> webapp
> > would have a custom class loader that loads
> resources
> > from the webapp directories - if I need system
> > resources I can always use the system class loader
> > instead. This is the way other app servers
> behave.
> >
> > The methods work properly if used to access
> resources
> > contained within the webapp's jars, but don't work
> to
> > retrieve plain files.
> >
> > Is this a known problem in Orion?
> >
> >
> > Roger Vaughn
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Auctions - Buy the things you want at great
> prices.
> > http://auctions.yahoo.com/
>
>
__________________________________________________
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/