Search code examples
javawebsphereclassloader

GetResourceAsStream not working on Websphere server


Application Server : IBM Websphere

Java 6

Issue :

Below is the folder structure of web application :

WEB-INF/libs/props/

The issue is below code is not working :

this.getClass().getResourceAsStream('/props'/+fileName) where fileName is a valid file name inside props folder of WEB-INF/lib/pros.

The class which is calling above method is inside a JAR and included in lib

The above call returns NULL.

The same set up works on tomcat with web application deployed in expanded mode integrated inside Inteliij IDE. On environment where this issue is coming , the application is deployed as ear Please help as I not able to get any clue on this


Solution

  • The jar files under WEB-INF/lib are in the classpath. Not WEB-INF/lib itself.

    The file should be in one of those jars, or under WEB-INF/classes (which is in the classpath)