-
Bug
-
Resolution: Not A Defect
-
Major
-
None
Trying to access a static resource in the the src/main/resources folder (or any of its subfolders) of any plugin generated through Maven 3 like in the following example:
URL url = getClass().getResource("/" + xmlFile);
File xmlFile = new File(url.getPath());
The following exception is thrown:
Caused by: java.io.FileNotFoundException: C:\Guglielmo\Software\Jenkins\1.551\fi
le:\C:\Users\Administrator\.jenkins\plugins\lc-plugin\WEB-INF\lib\classes.
jar!\ServerList.xml (The filename, directory name, or volume lab
el syntax is incorrect.)
at java.io.FileInputStream.<init>(FileInputStream.java:137)
at java.io.FileInputStream.<init>(FileInputStream.java:96)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection
.java:82)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon
nection.java:173)
But the ServerList.xml file is bundled in the classes.jar of this plugin (and the other custom plugins of ours) and it is loaded in the classpath (we are able to get its InputStream from there at runtime).
The code above works fine with Jenkins releases up to 1.547. It isn't working with the latest one 1.551 too.