How to find properties file inside a jar inside a war

Viewed 23

So I was building my project whose structure is given below:

WEB-INF
|
|---classes
|---lib
    |
    |--- my_jar1.jar
    |--- my_jar2.jar
    |--- my_jar3.jar
    |--- interested_jar.jar
            |
            |--- com
            |     |--- company
            |           |--- folder1
            |                  |--- folder2
            |                           |--- folder3
            |                                   |--- calling_class.java
            |--- META-INF
            |--- my_properties.properties

This is a servlet based application. Build is maven. I want to load my_properties.properties file from calling_class.java. There are many jars inside the war. The jars are bundled up in the war file. So far I've tried

InputStream ioStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("my_properties.properties");
Properties prop = new Properties();
prop.load(ioStream);
InputStream ioStream = getClass().getResourceAsStream("my_properties.properties");
Properties prop = new Properties();
prop.load(ioStream);

After the deployment, I'm getting NullPointException when loading the properties. Any help is greatly appreciated.

0 Answers
Related