tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juergen Baumann" <juergenbaum...@yahoo.com>
Subject Classloader issue - additional info
Date Fri, 15 Dec 2000 11:43:20 GMT
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(); 
}

Mime
View raw message