3

非常感谢所有愿意花时间阅读的人。

我正在努力制作一个 webstart Swing 1.4.2_12 应用程序以使用 java webstart 1.6.0_29 启动。

这是场景:

  1. 所有流量都通过 HTTPS 完成
  2. 用户单击网页上的链接以启动应用程序:servlet 生成的 jnlp 文件
  3. Java webstart客户端(1.6.0_29)一口气启动并加载应用程序
  4. 因为 jnlp 描述符中 j2se 版本设置为 1.4.2_12,所以使用 java webstart 1.4.2_12 来启动应用程序(由 1.6.0_29 加载)
  5. Java webstart 1.4.2_12 在启动时失败,声称它找不到某些幽灵“javaws2”文件

报告以下消息:

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)

完整的堆栈跟踪是:

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)
  • 禁用 HTTPS 时也会出现同样的错误。

以下两个 HTTP 标头都由 JNLP servlet 发送到客户端:

Cache-Control :empty
Pragma :empty

这些标头是防止 IE 在 HTTPS 模式下禁用缓存所必需的,这会阻止 java webstart 找到加载的 jnlp 文件(因为它没有被缓存)。

  • Mime-type 设置为:application/x-java-jnlp-file

  • 我不明白的是为什么 java 1.4.2_12 找不到 JWS 1.6.0_29 加载的 jnlp 文件?

谢谢阅读。

4

1 回答 1

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.

于 2012-09-20T12:30:24.477 回答