Description
Spring boot generated über jar for a simple CommandLineRunner
app currently does not support being executed from a Windows UNC path such as java -jar \\myhost\myshare\my-sb-app.jar
.
Boot first raises an Unable to determine code source archive
IllegalStateException
thrown by Launcher because path
variable don't get the leading "//" sequence.
This can be easily fixed by :
URI location = (codeSource == null ? null : codeSource.getLocation().toURI());
- String path = (location == null ? null : location.getPath());
+ String path = (location == null ? null : location.getSchemeSpecificPart());
if (path == null) {
Second is in ExecutableArchiveLauncher#createClassLoader where some wrong file://myhost/myshare/my-sb-app.jar
URL is added to the copy
variable while it should have been file:////myhost/myshare/my-sb-app.jar
and subsequently ripped off by #addDefaultClassloaderUrl
.
This time I don't know how to fix it for good (hence I'm not posting a PR), my dirty workaround is :
if (loader instanceof URLClassLoader) {
final URL badURL = MyApplication.class.getProtectionDomain().getCodeSource().getLocation();
final URL goodURL = getArchive().getUrl();
for (URL url : ((URLClassLoader) loader).getURLs()) {
if (url.equals(badURL)) {
url = goodURL;
}
if (addDefaultClassloaderUrl(urls, url)) {
copy.add(url);
}
}
}
loader
is sun.misc.Launcher$AppClassLoader
running from JRE 7.