Simon
Simon

Reputation: 4192

How can I load JAR from a resource not ending with *.jar in the JNLP resources tag?

I would like to run a JAR file with Java Web Start. Unfortunately, I have to load the JAR file dynamically (it is stored in Moodle). Hence, the link to the JAR file does not end on ".jar". It is actually a call to a PHP script which loads the JAR file dynamically. If I open the link with my browser, the JAR file is downloaded. Anyway, Java Web Start is not able to download it like that. I get the following exception:

com.sun.deploy.net.FailedDownloadException: Ressource konnte nicht geladen werden: http://localhost/moodle22/pluginfile.php/39/mod_assignment/my_file 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$DownloadTask.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

And the encapsulated exception:

java.io.IOException: Invalid jar file at com.sun.deploy.net.HttpDownloadHelper.download(Unknown Source) at com.sun.deploy.cache.Cache.downloadResourceToTempFile(Unknown Source) at com.sun.deploy.cache.Cache.downloadResourceToCache(Unknown Source) 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$DownloadTask.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

My JNLP file:

<?xml version="1.0" encoding="utf-8"?>
<jnlp codebase="http://localhost">
  <information>
    <title>Test</title>
    <vendor>Me</vendor>
    <homepage href="http://www.google.com"/>
    <description>Test</description>
    <offline-allowed/>
  </information>
  <security>
    <all-permissions/>
  </security>
  <resources>
    <java version="1.5+"/>
    <jar href="moodle22/pluginfile.php/39/mod_assignment/my_file"/>
  </resources>
  <application-desc>
    <argument>--argument</argument>
  </application-desc>
</jnlp>

If I reference the JAR with a direct link like that, everything works as expected:

<resources>
    <java version="1.5+"/>
    <jar href="moodle22/mod/assignment/type/something/tmp/test.jar"/>
</resources>

Upvotes: 0

Views: 1982

Answers (1)

Simon
Simon

Reputation: 4192

Thanks @Amadan!

Java Web Start actually can load JARs from resources that do not end with a ".jar". One only has to set the content type appropriate:

Content-type: application/java-archive

Then it works perfectly :-)

Upvotes: 1

Related Questions