JDK-6506479 : Applet caching not handling URIs consistently
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-12-20
  • Updated: 2013-01-09
  • Resolved: 2007-03-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u2 b01Fixed 7Fixed
Description
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2

A DESCRIPTION OF THE PROBLEM :
On upgrading to 1.6.0 from 1.5 all of the applets on our website failed to load, throwing a ClassNotFoundException.

I managed to get it working in the end - the issue is that we serve our signed JAR file from a page generated in PHP, and the presence of parameters in the URL in the ARCHIVE parameter of the APPLET tag was breaking the caching - it seems to correctly get the file from our website, but then the cache doesn't seem to be able to load the file from disc.

Basically in my test I created a file called jar.php, which returned either the JAR file (and appropriate headers) if the parameter work=1 was passed in the URL, and nothing if it wasn't. The APPLET tag we use is like this

<applet name='quoteline' id='quoteline' code=loader3.SunLoaderApplet.class archive='jar.php?work=1' codebase='http://devserv.throg.advfn.com:3029/' width='760' height='39'> etc.

This the trace of the relevant part:

network: Cache entry not found [url: http://devserv.throg.advfn.com:3029/jar.php?work=1, version: null]
network: Connecting http://devserv.throg.advfn.com:3029/jar.php?work=1 with proxy=HTTP @ /192.168.0.13:3128
network: Connecting http://devserv.throg.advfn.com:3029/jar.php?work=1 with cookie "nav_version=2; OASISID=4562fb50837b8; lang=gb"
network: Server http://devserv.throg.advfn.com:3029/jar.php?work=1 requesting to set-cookie with "lang=us; expires=Tue, 01-Jan-08 00:00:00 GMT; path=/"
network: Cache entry not found [url: http://devserv.throg.advfn.com:3029/jar.php, version: null]
network: Connecting http://devserv.throg.advfn.com:3029/jar.php with proxy=HTTP @ /192.168.0.13:3128
network: Connecting http://devserv.throg.advfn.com:3029/jar.php with cookie "nav_version=2; OASISID=4562fb50837b8; lang=us"
network: Downloading resource: http://devserv.throg.advfn.com:3029/jar.php
	Content-Length: -1
	Content-Encoding: null
network: Cache entry not found [url: http://devserv.throg.advfn.com:3029/loader3/SunLoaderApplet.class, version: null]
network: Connecting http://devserv.throg.advfn.com:3029/loader3/SunLoaderApplet.class with proxy=HTTP @ /192.168.0.13:3128
network: Connecting http://devserv.throg.advfn.com:3029/loader3/SunLoaderApplet.class with cookie "nav_version=2; OASISID=4562fb50837b8; lang=us"
network: Cache entry not found [url: http://devserv.throg.advfn.com:3029/loader3/SunLoaderApplet/class.class, version: null]
network: Connecting http://devserv.throg.advfn.com:3029/loader3/SunLoaderApplet/class.class with proxy=HTTP @ /192.168.0.13:3128
network: Connecting http://devserv.throg.advfn.com:3029/loader3/SunLoaderApplet/class.class with cookie "nav_version=2; OASISID=4562fb50837b8; lang=us"
load: class loader3.SunLoaderApplet.class not found.
java.lang.ClassNotFoundException: loader3.SunLoaderApplet.class
	at sun.applet.AppletClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.applet.AppletClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.applet.AppletClassLoader.loadCode(Unknown Source)
	at sun.applet.AppletPanel.createApplet(Unknown Source)
	at sun.plugin.AppletViewer.createApplet(Unknown Source)
	at sun.applet.AppletPanel.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
	at sun.applet.AppletClassLoader.getBytes(Unknown Source)
	at sun.applet.AppletClassLoader.access$100(Unknown Source)
	at sun.applet.AppletClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	... 10 more
basic: Exception: java.lang.ClassNotFoundException: loader3.SunLoaderApplet.class
Dump classloader list ...
    codebase=http://devserv.throg.advfn.com:3029/, key=http://devserv.throg.advfn.com:3029/,jar.php?work=1, zombie=false, cache=true, refcount=1, info=sun.plugin.ClassLoaderInfo@10064a4
Done.

As you can see the second part of the cache output is missing the trailing "?work=1" parameter.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a file called tmp.php in your webserver's root which has the following contents:

<?
    global $DOCUMENT_ROOT, $work;
    
    //$f = fopen("tmp.log", "a");
    //fwrite($f, "work = $work\n");
    //fclose($f);
    
    if ($work != "1")
        exit;

    Header("Content-type: application/x-java-archive");
    Header("Content-Disposition: attachment; filename=Test.class");

    readfile($DOCUMENT_ROOT . "/Test.class");

?>

and points at Test.class (replace with any applet) and a webpage with the following APPLET tag

<applet name='test' code=Test.class archive='jar.php?work=1' width='760' height='39'></applet>


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The applet should display correctly.
ACTUAL -
Applet fails to load with exception given above.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Change the location where we're serving the JAR file from so it doesn't require any parameters in the URL.

Release Regression From : 5.0u9
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
SUGGESTED FIX http://web-east.east/deployment/www/webrevs/ngthomas/6506479/webrev/
24-01-2007

EVALUATION problem is probably when the download engine decide to not cache the resource (last modified or expiration header missing), we download the resource to the tmp location using the url without the query string, which is not correct.
21-12-2006

EVALUATION i tried to reproduce the problem but no luck yet so far. i can load the applet correctly with applet tag: <APPLET CODE="HelloWorld.class" archive="jar.php?work=1" WIDTH=150 HEIGHT=25> </APPLET> basic: Loading applet ... basic: Initializing applet ... basic: Starting applet ... basic: completed perf rollup network: Cache entry not found [url: http://localhost/6506479/jar.php?work=1, version: null] network: Connecting http://localhost/6506479/jar.php?work=1 with proxy=DIRECT network: Downloading resource: http://localhost/6506479/jar.php?work=1 Content-Length: 1,859 Content-Encoding: null network: Wrote URL http://localhost/6506479/jar.php?work=1 to File C:\Documents and Settings\ngthomas\Application Data\Sun\Java\Deployment\cache\6.0\3\74ea3e83-1088b52d-temp network: Cache entry found [url: http://localhost/6506479/jar.php?work=1, version: null] 1.6.0 HelloWorld init() Will contact the customer for more information.
21-12-2006

EVALUATION This maybe a bug in our new cahce mechanism in JDK6.
20-12-2006