I have a maven project, working on Eclipse IDE. And I am trying to deploy it to the other linux machine having tomcat server, by export .war file from eclipse and put it to the other machine.
Here is the problem, when I execute(?) .war file by tomcat server, it automatically unzipped this file and make a project directory, however my resources in /src/main/resources
spreads over var/lib/tomcat7/webapps/{project-root}/WEB-INF/classes
and my original code to load some files doesn't work anymore
Here is the example.
String currentDir = System.getProperty("user.dir");
File mappingdir = new File(currentDir + "/src/main/resources/mapping");
File f = new File(mappingdir + "/a.csv");
Result
HTTP Status 500 - java.io.FileNotFoundException:
/var/lib/tomcat7/src/main/resources/mapping/a.csv (No such file or directory)
Because, this .csv file does not exists anymore.
Its location is /var/lib/tomcat7/webapps/{project-root}/WEB-INF/classes/mapping/a.csv
How should I change the directory while developing java standalone code - if I consider deploy it to the web server?
My question is very much related to this question. Read file from /src/main/resources/