1.6 Web Start will make a redundant download request for some jars

Using a network-traffic-sniffing tool, I noticed that one of my jar files was being downloaded redundantly when using JRE 1.6. When investigating the issue, I found that the SwingSet demo on Sun's Web Start demo page (http://java.sun.com/products/javawebstart/demos.html) exhibits the same behavior (the other demos do not). The following examples are from a download of the SwingSet demo.

The first jar request looks normal:

GET /products/javawebstart/apps/swingset2.jar HTTP/1.1

content-type: application/x-java-archive

accept-encoding: pack200-gzip,gzip

User-Agent: JNLP/6.0 javaws/1.6.0_01 (b06) Java/1.6.0_01

UA-Java-Version: 1.6.0_01

Host: java.sun.com

Cache-Control: no-cache

Pragma: no-cache

Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

Proxy-Connection: keep-alive

If-Modified-Since: Wed, 31 Dec 1969 23:59:59 GMT

After this request completes, the jar is downloaded as expected and the SwingSet window opens; although some of the images in the tool bar do not appear. At this point, a second request for the same jar is made.

GET /products/javawebstart/apps/swingset2.jar HTTP/1.1

User-Agent: Java/1.6.0_01

Host: java.sun.com

Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

Proxy-Connection: keep-alive

Obviously it has less header fields, and also it is interesting that the User-Agent appears to be the Java application itself rather than Web Start. Note that this is a GET request and it does not have an If-Modified-Since field, so the entire jar will be downloaded again even though it was cached after the first request.

After this request completes, the rest of the toolbar in the SwingSet window is filled in. Perhaps this additional request is somehow resource related?

This behavior does not occur in previous JREs, only in 1.6. Also, it does not occur with all jar files; the other demos on the Sun site do not exhibit this behavior.

The jar file in my application is quite large, so I would like to prevent this redundant jar download if possible. Do you know why this is occurring? Is there a way that I can structure my jar differently in order to prevent this from happening?

Thank you.

[2285 byte] By [jgreenAtWorka] at [2007-11-27 5:27:02]
# 1

I'm sorry I don't have an answer to your question but I wanted to add that I've noticed that my JNLP file is requested three times. The header is the same each time. I'm using NanoHTTPD for testing:

First request:

GET '/jnlptest/JnlpTest.jnlp'

HDR: 'pragma' = 'no-cache'

HDR: 'connection' = 'keep-alive'

HDR: 'ua-java-version' = '1.6.0_01'

HDR: 'cache-control' = 'no-cache'

HDR: 'accept' = 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2'

HDR: 'host' = 'localhost'

HDR: 'accept-encoding' = 'gzip'

HDR: 'user-agent' = 'JNLP/6.0 javaws/1.6.0_01 (b06) Java/1.6.0_01'

Second request:

GET '/jnlptest/JnlpTest.jnlp'

HDR: 'pragma' = 'no-cache'

HDR: 'connection' = 'keep-alive'

HDR: 'ua-java-version' = '1.6.0_01'

HDR: 'cache-control' = 'no-cache'

HDR: 'accept' = 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2'

HDR: 'host' = 'localhost'

HDR: 'accept-encoding' = 'gzip'

HDR: 'user-agent' = 'JNLP/6.0 javaws/1.6.0_01 (b06) Java/1.6.0_01'

Third request:

GET '/jnlptest/JnlpTest.jnlp'

HDR: 'pragma' = 'no-cache'

HDR: 'connection' = 'keep-alive'

HDR: 'ua-java-version' = '1.6.0_01'

HDR: 'cache-control' = 'no-cache'

HDR: 'accept' = 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2'

HDR: 'host' = 'localhost'

HDR: 'accept-encoding' = 'gzip'

HDR: 'user-agent' = 'JNLP/6.0 javaws/1.6.0_01 (b06) Java/1.6.0_01'

First and only request for the JAR:

GET '/jnlptest/JnlpTest.jar'

HDR: 'connection' = 'keep-alive'

HDR: 'accept-encoding' = 'pack200-gzip,gzip'

HDR: 'accept' = 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2'

HDR: 'pragma' = 'no-cache'

HDR: 'cache-control' = 'no-cache'

HDR: 'user-agent' = 'JNLP/6.0 javaws/1.6.0_01 (b06) Java/1.6.0_01'

HDR: 'content-type' = 'application/x-java-archive'

HDR: 'ua-java-version' = '1.6.0_01'

HDR: 'host' = 'localhost'

doRun.runa at 2007-7-12 14:48:20 > top of Java-index,Desktop,Deploying...
# 2
I noticed this too when using Ethereal to monitor the network packets and mentioned it in a bug report (6514485) for the JnlpDownloadServlet. The Sun developer said he would investigate but I don't know if anything has been done.
ghanemana at 2007-7-12 14:48:20 > top of Java-index,Desktop,Deploying...
# 3
I think I've figured out why JWS was downloading my JNLP file multiple times. The tiny web server (NanoHTTPD) I was using for testing does not provide the Last-Modified header in its responses. When I tested with either Jigsaw or Tomcat, the JNLP file was downloaded only once.
doRun.runa at 2007-7-12 14:48:20 > top of Java-index,Desktop,Deploying...