- assigned_to: nobody --> simontuffs
While experimenting deploying the Jetty server using onejar I’ve discovered a problem related to resource loading and URL’s.
What happens inside the Jetty server is that during startup an XML file located inside the Jetty jar file (which is embedded within the onejar jar file) is loaded as a URL object. Then the String representation of this URL is passed on to modules responsible for loading the XML content. When this module tries to open and read the file an exception is thrown as the URL is invalid.
I’ve managed to reproduce the problem with the following simple piece of code (Using org.apache.commons.io.IOUtils to write the content of the file to a String).
//Loading an XML file located in a JAR file wrapped in the onejar jar file
URL loadedUrl = loader.getResource("xml/testxml.xml");
URLConnection con = loadedUrl.openConnection();
System.out.println(IOUtils.toString(con.getInputStream()));
String loadedUrlAsString = loadedUrl.toString();
System.out.println(loadedUrlAsString);
URL newUrl = new URL(loadedUrlAsString);
con = newUrl.openConnection();
System.out.println(IOUtils.toString(con.getInputStream()));
The first System.out.println statement works fine, as the resource is loaded by onejar and the URL is valid.
The last System.out.println statement fails as the newURL object does not point to a valid location.
This piece of code executes without problems using onejar version 0.96, so it seems like the changes in version 0.97 have introduced this problem.
I will continue evaluating using onejar for deployment of Jetty servers and webapplications, using onejar version 0.96, and hopefully you’ll be able to fix this issue in future versions.