如何解决版本更新为Java WebStart
| 我正在将Java WebStart与正在使用的这个简单应用程序配合使用,并且我也做了此操作,以便它可以检查jar文件最新版本的更新。尽管在运行它时,我收到一条错误消息,指出服务器缺少版本响应。 以下是我的jnlp文件代码:<?xml version=\"1.0\" encoding=\"utf-8\"?>
<jnlp spec=\"1.0+\" codebase=\"http://localhost:8081/WebStartLauncher/app\" href=\"Agecalc.jnlp\">
<information>
<title>Jnlp Testing</title>
<vendor>Peter Ivan & co</vendor>
<homepage href=\"http://localhost:8081/WebStartLauncher\" />
<description>Testing Testing</description>
<icon href=\"app/index.jpeg\" kind=\"default\"/>
<icon kind=\"shortcut\" href=\"app/index.jpeg\" width=\"32\" height=\"32\"/>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version=\"1.6+\" />
<jar href=\"AgeCalc__V1.0.jar\" version=\"1.0\"/>
<jar href=\"AgeCalc__V1.1.jar\" version=\"1.1\"/>
<property name=\"jnlp.versionEnabled\" value=\"true\"/>
</resources>
<application-desc main-class=\"com.webstart.AgeCalculator\" />
</jnlp>
对于version.xml:
<jnlp-versions>
<resource>
<pattern>
<name>AgeCalc__V1.0.jar</name>
<version-id>1.0</version-id>
</pattern>
<file>AgeCalc__V1.0.jar</file>
</resource>
</jnlp-versions>
对于web.xml:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<web-app id=\"WebApp_ID\" version=\"2.4\" xmlns=\"http://java.sun.com/xml/ns/j2ee\"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\">
<display-name>WebStartLauncher</display-name>
<welcome-file-list>
<welcome-file>webstart.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>JnlpDownloadServlet</servlet-name>
<servlet-class>jnlp.sample.servlet.JnlpDownloadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>JnlpDownloadServlet</servlet-name>
<url-pattern>/WebContent/WEB-INF/lib</url-pattern>
</servlet-mapping>
</web-app>
这些是我得到的错误日志:
com.sun.deploy.net.FailedDownloadException: Unable to load resource: (http://localhost:8081/WebStartLauncher/app/AgeCalc__V1.0.jar,1.0)
at com.sun.deploy.net.DownloadEngine.actionDownload(UnkNown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(UnkNown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(UnkNown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(UnkNown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(UnkNown Source)
at com.sun.deploy.net.DownloadEngine.getResource(UnkNown Source)
at com.sun.javaws.launchdownload.downloadJarFiles(UnkNown Source)
at com.sun.javaws.launchdownload.downloadEagerorAll(UnkNown Source)
at com.sun.javaws.Launcher.downloadResources(UnkNown Source)
at com.sun.javaws.Launcher.preparelaunchFile(UnkNown Source)
at com.sun.javaws.Launcher.preparetoLaunch(UnkNown Source)
at com.sun.javaws.Launcher.launch(UnkNown Source)
at com.sun.javaws.Main.launchApp(UnkNown Source)
at com.sun.javaws.Main.continueInSecureThread(UnkNown Source)
at com.sun.javaws.Main$1.run(UnkNown Source)
at java.lang.Thread.run(UnkNown Source)
java.io.IOException: missing version response from server
at com.sun.deploy.net.DownloadEngine.actionDownload(UnkNown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(UnkNown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(UnkNown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(UnkNown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(UnkNown Source)
at com.sun.deploy.net.DownloadEngine.getResource(UnkNown Source)
at com.sun.javaws.launchdownload.downloadJarFiles(UnkNown Source)
at com.sun.javaws.launchdownload.downloadEagerorAll(UnkNown Source)
at com.sun.javaws.Launcher.downloadResources(UnkNown Source)
at com.sun.javaws.Launcher.preparelaunchFile(UnkNown Source)
at com.sun.javaws.Launcher.preparetoLaunch(UnkNown Source)
at com.sun.javaws.Launcher.launch(UnkNown Source)
at com.sun.javaws.Main.launchApp(UnkNown Source)
at com.sun.javaws.Main.continueInSecureThread(UnkNown Source)
at com.sun.javaws.Main$1.run(UnkNown Source)
at java.lang.Thread.run(UnkNown Source)
请告知如何进行。非常感谢!
解决方法
我认为,基于http://docs.oracle.com/javase/7/docs/technotes/guides/javaws/developersguide/downloadservletguide.html#requests,您正在混合两种可能的基于版本的下载策略。对于任何jar资源,您都可以使用文件名约定,在这种情况下不需要version.xml条目,并且jnlp条目将显示为
<jar href=\"AgeCalc.jar\" version=\"1.0\"/>
并且servlet将自动使用AgeCalc__V1.0.jar。
另一种可能的方式是写
<resource>
<pattern>
<name>AgeCalc.jar</name>
<version-id>1.0</version-id>
</pattern>
<file>AgeCalc__V1.0.jar</file>
</resource>
在您的version.xml中,结合上面更改过的jnlp。但是由于您使用的是文件名约定,所以我建议完全不要使用version.xml。
当jnlp中的href包含__V时,DownloadServlet可能会出现问题。
但是从Java 7开始,您甚至不再需要下载servlet。现在,客户可以做魔术。您所要做的就是将一个值为true的系统属性jnlp.versionEnabled添加到您的jnlp中。只要服务器上的文件采用* __ V $ {version} .jar格式,一切都将正常运行。
但是您可以使用我的gradle插件,该插件将自动创建正确的Webstart目录,准备打包以进行部署。
, 您应该检查文件名。
AgeCalc__V1.0.jar和AgeCalc_V1.0.jar不同。
重命名jar文件时,请确保在版本号之前包含两个下划线(__)。
<resources>
<j2se version=\"1.6+\" />
<jar href=\"AgeCalc.jar\" version=\"1.0\"/>
<jar href=\"AgeCalc.jar\" version=\"1.1\"/>
<property name=\"jnlp.versionEnabled\" value=\"true\"/>
</resources>
档案名称
AgeCalc__V1.0.jar和
AgeCalc__V1.1.jar
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。