Java WebStart 版本更新

发布于 2024-11-10 15:47:57 字数 4557 浏览 1 评论 0原文

我将 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)

请告知如何继续。非常感谢!

I'm using Java WebStart with this simple application that I'm working on and I have also made it so that it would be able to check for updates for the latest versions of the jar file. Although when running it, I get an error message saying that there is a missing version response from the server.

below is my code for the jnlp file:

<?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>

for the 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>

for the 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>

and these are the error logs that i get:

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)

Please advise on how to proceed. Many thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深白境迁sunset 2024-11-17 15:47:57

基于 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>

结合上面更改的 jnlp 写入 version.xml 。但由于您使用的是文件名约定,我建议根本不要使用 version.xml。

当 jnlp 中的 href 包含 __V 时,DownloadServlet 可能会出现问题。

但从 Java 7 开始,您甚至不再需要下载 servlet。现在客户可以施展魔法了。您所要做的就是向您的 jnlp 添加一个值为 true 的系统属性 jnlp.versionEnabled 。只要服务器上的文件采用 *__V${version}.jar 形式,一切都会正常工作

但是你可以使用 我的 gradle 插件,它会自动创建一个正确的 webstart 目录,准备好打包以供部署。

Based on http://docs.oracle.com/javase/7/docs/technotes/guides/javaws/developersguide/downloadservletguide.html#requests I think, that you are mixing two possible strategies for version based download. For any jar resource, you can use either filename convention, where you don't need a version.xml entry and your jnlp entry would read

<jar href="AgeCalc.jar" version="1.0"/>

and the servlet would automagically use AgeCalc__V1.0.jar.

The other possible way would be to write

<resource>
   <pattern>
     <name>AgeCalc.jar</name>
     <version-id>1.0</version-id>
   </pattern>
   <file>AgeCalc__V1.0.jar</file>
</resource>

in your version.xml in combination with the changed jnlp from above. But since you are using the file name convention, I would suggest not using the version.xml at all.

Maybe the DownloadServlet has problems when the href in the jnlp contains __V.

But starting with Java 7 you don't even need the download servlet any more. Now the client can do the magic. All you have to do is add a system property jnlp.versionEnabled with value true to your jnlp. As long as the files on the server are in *__V${version}.jar form, everything will work correctly.

But you can use my gradle plugin, which will automatically create a correct webstart dir, ready to be packed for deployment.

迷迭香的记忆 2024-11-17 15:47:57

您应该检查文件名。

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

You should check file name.

AgeCalc__V1.0.jar and AgeCalc_V1.0.jar are different.

While renaming the jar file make sure you include two underscores (__) before version number.

<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>

File names
AgeCalc__V1.0.jar and
AgeCalc__V1.1.jar

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文