Your webapp is in a different classloader. Webapps each get their own new classloader.
Use something like this: ClassLoader loader = getClass().getClassLoader(); Will Stranathan On Wed, 3 Oct 2001 11:49:29 -0700 "Haller, Joe" <[EMAIL PROTECTED]> wrote: > I have a class that loads initialization properties > from a .properties text file in the same directory as the > class. > > The class resides in > /TOMCAT_HOME/webapps/myapp/WEB-INF/classes/com/company/app/PropertiesClass.c > lass > Properties reside in > /TOMCAT_HOME/webapps/myapp/WEB-INF/classes/com/company/app/PropertiesFile.pr > operties > > I have a static initializer in PropertiesClass that > builds the properties as > follows: > > ... > ClassLoader loader = ClassLoader.getSystemClassLoader(); > URL url = > loader.getResource("com/company/app/PropertiesFile.properties"); > File file = new File(url.getFile()); > FileInputStream in = new FileInputStream(file); > Properties props = new Properties(); > props.load(in); > ... > > Loading the properties in stand-alone through a test main > method executes > correctly: > > i.e. > > /TOMCAT_HOME/webapps/myapp/WEB-INF/classes> java > com.company.app.PropertiesClass > > However, when I use this class in Tomcat 4.0 the static > initializer cannot > find > the file. The class is being loaded but the > .getResource() method in line 2 > above > is not working correctly. > > Any ideas here? > > Many thanks. > J. Haller