tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Renaud Bruyeron" <bruye...@fullsix.com>
Subject Re: Problem reading resource file in WEB-INF\lib
Date Thu, 15 May 2003 20:00:27 GMT

----- Original Message ----- 
From: "Jonathan Tiu" <Jonathan.Tiu@crystaldecisions.com>
Newsgroups: gmane.comp.jakarta.tomcat.user
Sent: Thursday, May 15, 2003 6:51 PM
Subject: RE: Problem reading resource file in WEB-INF\lib


>
> It attempts to load the resource file (invuca.icu) like this:
>
> String invdat = "/com/ibm/icu/impl/data/invuca.icu";
> InputStream i = invdat.getClass().getResourceAsStream(invdat);
> BufferedInputStream b = new BufferedInputStream(i, 110000);
>
> is it that it uses a classloader that isn't looking in WEB-INF\lib??

That's broken and won't work.
The code needs to use the TCL to load the resource, here it's using a system
classloader
(same as the one that loaded java.lang.String)

It should do something along the lines of:

String invdat = "/com/ibm/icu/impl/data/invuca.icu";
InputStream i =
Thread.currentThread().getContextClassLoader().getResourceAsStream(invdat);
BufferedInputStream b = new BufferedInputStream(i, 110000);

this classloader should have access to WEB-INF/lib/*.jar provided you are
doing this in a request thread,
not your own thread.

 - Renaud


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.478 / Virus Database: 275 - Release Date: 06/05/2003


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message