You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Juergen Baumann <ju...@yahoo.com> on 2000/12/15 12:43:20 UTC
Classloader issue - additional info
I use Tomcat 3.2 under Windows2000 Pro.
----- Original Message -----
From: Juergen Baumann
To: tomcat-user@jakarta.apache.org
Sent: Friday, December 15, 2000 12:36 PM
Subject: Classloader issue
I try to load files in an InputStream (using ClassLoader) in the init() method of a Servlet that is loaded on startup. The files reside in a .jar file that contains all the classes as well.
Using ClassLoader works fine in a stand-alone application, however, as soon as I try to make it work together with Tomcat using Servlets, I get the message: cannot load Servlet: ...
Here is the relevant code.
Thanks a lot in advance,
JB
init() method of Servlet:
-------------------------
...
try {
Items items_F = new Items("test1");
context.setAttribute(Items.F_KEY, items_F);
} catch (IOException e) {
context.log("No item property file" , e);
return;
}
....
Items class:
------------
public Items(String name) throws IOException {
this.items = new Properties();
InputStream is;
if (name.equals("text1") ) {
is = ClassLoader.getSystemResourceAsStream("items/items.text1");
} else if (name.equals("text2") ) {
is = ClassLoader.getSystemResourceAsStream("items/items.text2");
}
...
this.items.load(is);
is.close();
}