I have a war file is packaged in ear and deployed. Here is the structure:
EAR
-WAR
--input.txt
--META-INF
--WEB-INF
---classes
(and so on)
I am trying to read input.txt from one of the classes (say abc.xyz.Myclass) in WEB-INF/classes folder. Here is what I tried:
this.getClass().getClassLoader().getResourceAsStream("../../input.txt");
and
Thread.currentThread().getContextClassLoader().getResourceAsStream("../../input.txt");
I tried several paths like "../input.txt" or "/input.txt" or just "input.txt" by attaching a debugger. But every time I am getting NULL as return value (means it is not able to find the file).
What is the correct way to access that file in war irrespective of whether war is deployed standalone or it is packed in ear? Please help.