Java WebStart with version Update
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.p开发者_开发问答repareToLaunch(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!
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.
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
精彩评论