gpt4 book ai didi

Java WebStart 版本更新

转载 作者:行者123 更新时间:2023-11-30 07:32:56 28 4
gpt4 key购买 nike

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

对于版本.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 形式,everything will work correctly .

但是你可以使用my gradle plugin ,这将自动创建一个正确的 webstart 目录,准备打包部署。

关于Java WebStart 版本更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6196920/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com