3

I was looking for a solution of this problem for weeks now, but did not find anything, which really related to my problem / or I already tried all suggested solutions, without any success.

I have a JNLP file, which is downloaded by the javaws properly (I think), but then before launching, it complains about not finding some files in the /tmp directory. Exact error message is:

CouldNotLoadArgumentException[ Could not load file/URL specified: /tmp/tmp_cache8259898691262575141.tmp]
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.access$000(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: /tmp/tmp_cache8259898691262575141.tmp (Nincs ilyen fájl vagy könyvtár)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
    ... 5 more

I checked the /tmp, the folder is of course there, and is writable. Funny thing is, that during downloading the tmp_cacheNNNNNN.tmp files are there! They appear one-by-one, as the download progress moves on. However when the download is finished something (javaws?) deletes all of them, and then starts to complain about missing them.

I have JNLP caching turned on (and intend to have it cached locally). I tried with JRE 1.8.0_40, 1.8.0_65, 1.8.0_66, all gives the same result. Same result on windows and linux, both complain about missing files in the temp folder. The last JRE I managed to start is the 1.8.0_25, and seems to work with 1.8.0_72 (beta). However the downloaded jar files are still not cached! (if I open up the jcontrol application and look into the cache, the JAR files are not there, and I also don't know why).

My JNLP looks like this:

<?xml version="1.0" encoding="utf-8"?>

<jnlp spec="7.0+"
      codebase="http://localhost:8080/jbaf-server/jnlp/swing-client"
      href="http://localhost:8080/jbaf-server/clientDownload/client.jnlp" >
    <information>
        <title>Swing Client</title>
        <vendor>www.xy.z</vendor>
        <description>Swing Client</description>
        <description kind="short">Swing Client</description>
        <homepage href="www.xy.z"></homepage>

        <icon href="images/jnlp-icon.png"/>
        <icon kind="splash" href="images/jnlp-splash.png"/>

        <offline-allowed/>

    </information>
    <security>
        <all-permissions/>
    </security>
    <resources>
        <j2se version="1.8+" initial-heap-size="256m" max-heap-size="1024m"/>


    <property name="jnlp.versionEnabled" value="true" />
    <jar href="jbaf-swing-client.jar" version="0.3.0" main="true"/>
.... (lots of jar files)
    <jar href="spring-expression.jar" version="4.2.3.RELEASE"/>
    <jar href="spring-tx.jar" version="4.2.3.RELEASE"/>
    <jar href="commons-codec.jar" version="1.10"/>


    </resources>
    <application-desc main-class="org.jbaf.swingclient.Main">
        <argument>http://localhost:8080/jbaf-server</argument>
        <argument>false</argument>
    </application-desc>
</jnlp>

The JARs are signed with self-signed cert.

I have no idea why this happens. Anyone faced such a problem?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
user1536873
  • 81
  • 1
  • 10
  • Have you looked at [the logs](http://stackoverflow.com/a/11992492/829571)? – assylias Jan 19 '16 at 14:10
  • Yes, I tried, but since this error occures during the download stage, there are no logs, the java console isn't opened yet, and despite I set the trace level to ALL, no log files are generated. The Download progress goes to the end, and I get immediately an error dialog "Unable to start application" with the stacktrace given above. – user1536873 Jan 20 '16 at 05:30
  • OK, I managed to turn on the traceing. But I did not found any error. The javaws downloads the files, and then spawns a new JRE process with arguments to the downloaded jnlp file in the /tmp directory. Then the javaws exits, but then the new JRE does not find the file. It seems that during exit the javaws removes the temporary files since it marks the files created with the "deleteOnExit". Seems the JVM exits, before the new JVM is started. With 1.8.0_72 (BETA!) this is not happening, seems it waits enough before exit. Even if I start the javaws with the -import switch, it doesnt save to cache – user1536873 Jan 20 '16 at 09:43
  • If it works with a version but not with another you may want to file a bug on openjdk. – assylias Jan 20 '16 at 10:02
  • That one may be related: https://bugs.openjdk.java.net/browse/JDK-8069161 - the backport in Java 8 targets update 72, which would match your observations: https://bugs.openjdk.java.net/browse/JDK-8140130 – assylias Jan 20 '16 at 10:05
  • 1
    Thanks for the links, but these are related to slow cache performance. With JDK 1.8.0_72 (BETA) the application starts up from the cache significantly faster, than with previous version (including the latest official release u66). – user1536873 Jan 20 '16 at 12:56

1 Answers1

3

Finally I managed to find the problem!

It was caused by following HTTP headers set by Tomcat:

I did not set these headers in my Servlets, but it seems that these were added by some of the filter previously. I set these header values to "" (empty string), and the JDK started to cache my files, and the application was started finally OK!

However if you set the Cache-Control to no-cache, the JDK still fails to start the application. The files are saved to the System/User temp directory, but afterwards it will not start, because the temp files are removed. This was only working with JDK 1.8.0_72 (BETA), all previous version failed!

Long story short: if you have problems with your JNLP where the WebStart tells you not finding files in the temp directory, check your HTTP Response Headers!

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25
user1536873
  • 81
  • 1
  • 10
  • Why did you set it to empty string? Was this found by trial and error? (Is there even defined behavior what is supposed to happen if these headers are empty?) – StackzOfZtuff Apr 27 '18 at 09:14
  • I set it to empty string, because there is no way to remove it from the HTTP header which is already set by the container or some filter before. – user1536873 Mar 20 '20 at 07:58