I have a Java Spring application (maven) with a TranslationService class, which returns translated string from a JSON file (backend.json) ..
When I build my project (mvn clean package
) I get my {project}-{version}.jar file. If I execute this file (java -jar target/*.jar
), all works perfectly,
I can see my page, and everything works.
But I have one problem now. In the production version of my project I use Apache2 with VirtualHost. My test config looks like:
<VirtualHost *:80>
ServerName myloc
ProxyPass / http://localhost:8080/
</VirtualHost>
I can still see my page and fill my forms etc.. But if I after my final submit, my application sends me an email and creates a pdf for me. But my application crashes, because it can not translate my stuff, because it says, it cant find my file. But in my default (tomcat) version it worked fine.
static String getTranslation(String lang, String jsonKey) {
try {
File file = new File("./src/main/resources/static/i18n/"+lang+"/backend.json");
JsonReader reader = Json.createReader(FileUtils.openInputStream(file));
// ...
error:
"message":"java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.io.FileNotFoundException: File './src/main/webapp/i18n/de/backend.json' does not exist"