getResourceAsStream not loading resource in webapp
        Posted  
        
            by mangst
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by mangst
        
        
        
        Published on 2010-04-16T13:42:59Z
        Indexed on 
            2010/04/16
            13:53 UTC
        
        
        Read the original article
        Hit count: 334
        
I have a web application that uses a library which resides in TOMCAT_HOME/common/lib. This library looks for a properties file at the root of the classpath (in a class called ApplicationConfig):
ApplicationConfig.class.getResourceAsStream("/hv-application.properties");
My Tomcat web application contains this properties file. It is in WEB-INF/classes, which is the root of the classpath right? However, at runtime, when it tries to load the properties file, it throws an exception because it can't find it (getResourceAsStream returns null).
Everything works fine if my application is a simple, standalone Java application. Does Tomcat cause the getResourceAsStream method to act differently? I know there's a lot of similar questions out there, but none of them have helped unfortunately. Thanks.
© Stack Overflow or respective owner