I have a class X which needs to load a .properties file. Here is a code snippet:
ClassLoader cl = this.getClass().getClassLoader(); InputStream stream = cl.getResourceAsStream(/data/x.properties); It works just fine from my JUnit test for X. Now, I would like this class to be called from the servlet, which would run inside Tomcat 5.5.9. The only way to get that to work is to place my x.properties file inside the package the class X lives in. Well, I'd rather not to mix properties with classfiles. Another way, I can load that file, is to use servlets getServletContext() method. However, that would mean I need to pass the InputStream from the servlets to my class X. Well, I'd rather not to change X to use its caller to get X's properties file. I guess, what I need to do is to add the WEB-INF or ROOT dir of my webapp to the classpath, so the classloader can find it. Or is there some other way of accomplishing it? I think I am missing something fundamental ... cos that doesn't seem to be too strange of a requirement ... Any ideas? Thanks, maciek