I am facing a problem while developing a standalone web application compiled with Maven.
I am using a third-party software (Tom Sawyer) inside the program that needs to be pointed to a file outside the JAR file. Besides, I am only able to feed it a File location (ie. C:path/to/file.json
or /../../file.json
) via a user interface.
However, whatever I feed the software I get an error FileNotFound :
java.io.FileNotFoundException: JAR entry project/..\..\..\..\modelData.json not found in C:\Users\victor\Desktop\ea-prototype\Workspace\3_WEB\CSM\webappCSM_v0.1\target\Model-1.0.6-SNAPSHOT.jar!/BOOT-INF/classes
at org.springframework.boot.loader.jar.JarURLConnection.throwFileNotFound(JarURLConnection.java:178) ~[Model-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.springframework.boot.loader.jar.JarURLConnection.connect(JarURLConnection.java:101) ~[Model-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.springframework.boot.loader.jar.JarURLConnection.getInputStream(JarURLConnection.java:165) ~[Model-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at java.base/java.net.URL.openStream(URL.java:1152) ~[na:na]
I would like to know if the JarURLConnection is able to process a file from outside the Jar, and if yes, will /..
or /.
allow the software to 'climb out' of the Jar ?
Thanks
I have found the solution to my problem. It is very specific to the related sofware I am using. Anyway here it goes :
I checked the option 'URL' instead of 'File Path' and wrote a file URL location ie.
file:///C:/path/to/my/file.json
Though, it will only work with absolute paths and not with relative paths.