FileNotFoundException starting 1.4.2 webstart application with java webstart 1.6 over HTTPS

孤人 提交于 2020-01-14 14:49:28

问题


And many thanks to all who will take time for reading.

I'm struggling to make a webstart Swing 1.4.2_12 application to launch with java webstart 1.6.0_29.

Here is the scenario :

  1. All traffic is done over HTTPS
  2. User clics a link on a web page to launch the application : servlet generated jnlp file
  3. Java webstart client (1.6.0_29) starts and loads the application in a breath
  4. Because the j2se version is set to 1.4.2_12 in jnlp descriptor java webstart 1.4.2_12 is used to launch the application (loaded by 1.6.0_29)
  5. Java webstart 1.4.2_12 fails on startup claiming that it cannot find some ghost "javaws2" file

The following message is reported:

CouldNotLoadArgumentException[ Could not load specified file/URL : C:\DOCUME~1\BENOIT~1.VAT\LOCALS~1\Temp\javaws2]
    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)

Full stacktrace is:

java.io.FileNotFoundException: C:\DOCUME~1\BENOIT~1.VAT\LOCALS~1\Temp\javaws2 (File not found)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(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)
  • The same error occurs when HTTPS is disabled.

Both the following HTTP headers are sent to the client by JNLP servlet :

Cache-Control : empty
Pragma : empty

These headers are necessary to prevent IE to disable caching in HTTPS mode wich prevents java webstart to find the loaded jnlp file (because it is not cached).

  • Mime-type is set to : application/x-java-jnlp-file

  • What I do not understand is why java 1.4.2_12 cannot find the jnlp file loaded by JWS 1.6.0_29 ?

Thanks for reading.


回答1:


@Andrew : Thank you for your interest.

Here comes my conclusions on that issue.

In a nutshell : Always set the href attribute in the the jnlp tag !

<jnlp spec="1.0+" codebase="htt://myhost/codebase" href="mustSetThisAbsolutelyForJWS-1.4.2_12.jnlp">
...
</jnlp>

Multiple HTTP debug sessions have shown that :

Scenario 1: href attribute is left empty and JNLP files are associated with JWS 1.6 on the client

  1. User clicks a jnlp link, JNLP file is downloaded and cached by browser.
  2. JWS 1.6.0_29 starts up then read the downloaded JNLP file.
  3. JWS 1.6.0_29 downloads all JAR files and then switches to JWS 1.4.2_12.
  4. JWS 1.4.2_12 starts up and then obviously read the JNLP file in its turn.
  5. JWS 1.4.2_12 tries to retrieve the JNLP file pointed by the href attribute.
  6. Since href is empty, JWS reports "Could not load specified file/URL : C:\DOCUME~1\BENOIT~1.VAT\LOCALS~1\Temp\javaws2". (As a side note, ghost javaws2 is sometimes named javaws10 or similar)

Please note : When using JWS 1.4 or 1.5 with this scenario, the application WILL start. The issue only appears when JWS 1.6 is used to run a 1.4.2_12 application. JWS 1.5 and 1.6 do not fail when no href attribute is set. Instead they simply use the JNLP as is, check the JAR updates and then launch the application.

Scenario 2: href attribute is set with a proper value and JNLP files are associated with JWS 1.6 on the client

  1. User clicks a jnlp link, JNLP file is downloaded and cached by browser.
  2. JWS 1.6.0_29 starts up then read the downloaded JNLP file.
  3. JWS 1.6.0_29 downloads all JAR files and then switches to JWS 1.4.2_12.
  4. JWS 1.4.2_12 starts up and then obviously read the JNLP file in its turn.
  5. JWS 1.4.2_12 tries to retrieve the JNLP file pointed by the href attribute.
  6. JWS 1.4.2_12 downloads the JNLP pointed by the href attribute.
  7. JWS 1.4.2_12 downloads all JNLP JAR files referenced in the freshly downloaded JNLP file.
  8. JWS 1.4.2_12 launches the application correctly.

It's been a major pain in the neck for me and took me days to figures this out. Hope this will help someone one day.



来源:https://stackoverflow.com/questions/12421950/filenotfoundexception-starting-1-4-2-webstart-application-with-java-webstart-1-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!