I am trying to access a properties file from java and it works file when I run it as a stand-alone java application. But, when I call the method accessing the file from a jsp page running on a tomcat server, I get a FileNotFoundException.
I think that when the files are deployed into a server, their path changes, and thats why the exception occurs from a web-app but not directly in java. Below is the project explorer view of my project.
I am accessing the nWMS properties file from the LabelRequestMessages class in java. Below is the code with which I access the file in java.
in = new FileInputStream("resources-dev/com/infosys/gidl2/shiplabel/mybatis/config/"
+ propsDB); //propsDB has the file name
props.load(in);
Could someone please tell me how to provide the path so that the file is accessible when deployed in a tomcat server.
You are trying to get resources inside your .war
application please consider using that
private static final String ENDINGS_FILE_NAME = "com/infosys/gidl2/shiplabel/mybatis/config/" + propsDB;
...
InputStream is = getClass( ).getResourceAsStream(ENDINGS_FILE_NAME);
But first remember to set resources folder in your web.xml
, because tomcat needs to know where search it.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments