简体   繁体   中英

Java Web Start can't find jar with formatted version filename

I have simple-as-can-be Web Start application sitting on a file server. The directory consists of the following:

foo__V1.1.jar
runfoo.jnlp

The contents of runfoo.jnlp is as follows:

<?xml version="1.0" encoding="utf-8"?>
  <jnlp spec="1.0+" href="http://myserver.com/runfoo.jnlp" codebase="http://myserver.com">
  <information>
    <title>Foo</title>
  </information>
  <security>
    <all-permissions/>
  </security>
  <resources>
    <j2se version="1.7.0_06+" href="http://java.sun.com/products/autodl/j2se" />
    <jar href="foo.jar" main="true" version="1.0+"/>
    <property name="jnlp.versionEnabled" value="true"/>
  </resources>
  <application-desc name="Foo" main-class="com.myserver.foo.Foo" width="640" height="480" />
  <update check="always" policy="always" />
</jnlp>

The issue is that Web Start is attempting to access a file at http://myserver.com/runfoo.jnlp?version-id=1.0%2B , and not finding it.

I assume there's some extra step required to have Web Start automatically grab the latest jar version in this simple instance, but after a lot of Googling all I've found is the same steps over and over:

  • rename file to <file_name>__V<versionnumber>.jar
  • Add the versionEnabled property to the jnlp
  • enjoy versioned goodness

The jnlp file runs absolutely fine when I specify an explicit file name, but always fails when I've tried to implement versioning.

I'm sure I'm missing something vital but I haven't been able to find it anywhere. I'm guessing that although my set-up is simple, it's not simple-as-can-be-and-also-work.

Any help will be much appreciated :)


The explicit exception is:

com.sun.deploy.net.FailedDownloadException: Unable to load resource: (http://myserver.com/foo.jar?version-id=1.0%2B, 1.0+)

I've also tried removing the + from the version specification and the same error occurs (apart from a missing plus of course). Writting foo__V1.1.jar in the jnlp file works but of course defeats the whole point of this.

The versioned file names are a convention used by the JNLP download servlet to know what to serve when the client asks for lib.jar?version=something . You need the download servlet on the server side (or you need to duplicate its behaviour in mod_rewrite rules or similar), just the plain files with versions names is not enough.

For followers, a similar issue for me

java.io.IOException: Error returned: 10 Could not locate resource
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

"unable to launch application"

com.sun.deploy.net.FailedDownloadException: Unable to load resource: (http://host:port/webapp_name/app/jar-name.jar?version-id=1.5.0-20160707.182810-19, 1.5.0-20160707.182810-19)
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

meant "the special internal file version.xml didn't match up right with the filenames deployed and existent in the web-app directory":

ref: http://docs.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/downloadservletguide.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM