无法使用Java WebStart在JNLP中启动弹簧引导
问题描述:
编辑过的问题。我试图在JNLP中运行spring启动应用程序,但在解决所有安全问题后,仍然出现此错误。它在启动时的弹簧引导初始化期间发生。它与弹簧启动生命周期有关,显然与保护领域有关,但我真的不知道如何解决它。 JAR在作为独立应用运行时运行得非常完美,其中包含java -jar Test.jar
。从Java Webstart的控制台无法使用Java WebStart在JNLP中启动弹簧引导
例外:
Unable to determine code source archive from \\localhost:8080\jnlp\Test.jar
org.springframework.boot.loader.Launcher.createArchive(Launcher.java:151)
at org.springframework.boot.loader.PropertiesLauncher.<init>(PropertiesLauncher.java:149)
at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:607)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
的例外Launcher.java
(弹簧引导工具)时:
protected final Archive createArchive() throws Exception {
ProtectionDomain protectionDomain = getClass().getProtectionDomain();
CodeSource codeSource = protectionDomain.getCodeSource();
URI location = (codeSource == null ? null : codeSource.getLocation().toURI());
String path = (location == null ? null : location.getSchemeSpecificPart());
if (path == null) {
throw new IllegalStateException("Unable to determine code source archive");
}
File root = new File(path);
if (!root.exists()) {
throw new IllegalStateException(
"Unable to determine code source archive from " + root);
}
return (root.isDirectory() ? new ExplodedArchive(root)
: new JarFileArchive(root));
}
春天开机不能够得到绝对执行的弹簧启动jar的路径 - 它只传递格式的URI,在我的情况下\ localhost:8080 \ jnlp \ Test.jar,通常location
指向th e文件的绝对URI。因此,Spring引导无法在Java WebStart中初始化。
我的JNLP:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/" href="Test.jnlp">
<information>
<vendor>TEST</vendor>
<homepage href="http://localhost:8080/" />
<description>Testing Testing</description>
</information>
<update check="timeout" policy="always"/>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.8+" />
<jar href="/jnlp/Test.jar" />
</resources>
<application-desc main-class="org.springframework.boot.loader.PropertiesLauncher" />
</jnlp>
任何提示如何推Launcher.java
绝对文件路径没有固定弹簧启动库?
更新:我看到这不能很容易解决...... Spring引导根本不支持从非文件(或非servlet)位置运行,因为它可以与自定义类加载器一起工作。此外,path
变量应该与被执行的jar相同,所以不可能将引导指向新下载的文件(实际上是同一个jar)。 :(
答
The solution was to add the MODULE layout for the plugin in the pom.xml file
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>MODULE</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
你找到一个解决办法? – Bhargav
号时,不支持,不从春季开发者。 – Mejmo
所以春天的引导回复不支持JNLP? – Bhargav