JDK-6655785 : Plug-in doesn't request jar correctly when applet dynamically added to DOM in IE
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-01-28
  • Updated: 2011-02-16
  • Resolved: 2008-01-28
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_10-ea"
Java(TM) SE Runtime Environment (build 1.6.0_10-ea-b09)
Java HotSpot(TM) Client VM (build 11.0-b09, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Internet Explorer 7.0.5730.11IS
Microsoft Windows XP Professional Version 2002 Service Pack 2

A DESCRIPTION OF THE PROBLEM :
Using javascript it is possible to dynamically add an empty DIV tag to the end of a HTML page and subsequently set the innerHTML of that DIV to refer to an applet jar. This should result in the applet being loaded and started. However the 1.6_0_10 plug-in initially fails to request the jar file correctly, resulting in a dialog being launched indicating a ClassNotFoundException has occurred. Subsequently a second dialog appears indicating a NullPointerException.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1)Generate a jar using the SimpleLiveConnectApplet2 class provided - in the HTML test page this jar is named 'simpleLiveConnect.jar'. NOTE: This problem is seen only when an applet is run from a jar. Using a simple applet class referenced directly does not exhibit the problem

2) Make this jar available on a web server along with the test HTML page provided.

3) Using IE 7 Browse to the the test HTML page provided

4) Close the browser

4) Modify the test HTML page to comment out the section that handles dynamic loading of the applet and uncomment the applet tag so that it will be loaded directly

5) Using IE 7 browse to the test HTML page again

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using plugin version 6 build 1.6.0_10-ea-b09 with IE 7 I expect the SimpleLiveConnectApplet2 applet to load and start without any problems when browsing to the test HTML page
ACTUAL -
Browsing to the test HTML page using IE7 and plugin version 6 build 1.6.0_10-ea-b09 when the applet is dynamically loaded results in an 'Application Error' dialog reporting:

java.lang.ClassNotFoundException: SimpleLiveConnectApplet2.class

Subsequently a dialog appears reporting a second Application Error, this time specifying :

java.lang.NullPointerException: component argument pData

Looking at the http request log on the web server shows three requests received in the following order:

http://localhost/WebServerRoot/SimpleLiveConnectApplet2.class
http://localhost/WebServerRoot/SimpleLiveConnectApplet2/class.class
http://localhost/WebServerRoot/simpleLiveConnect.jar

After dismissing the 'Application Error' dialogs, a thread list from the java console shows that the SimpleLiveConnectApplet2 applet has been loaded and is running

Using the same browser and plugin to load the test HTML page containing a direct APPLET tag instead of the javascript to dynamically add the applet results in the applet being loaded and started correctly without any 'Application Error' dialogs.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Java Plug-in 1.6.0_10-ea
Using JRE version 1.6.0_10-ea Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\dara
network: Loading user-defined proxy configuration ...
network: Done.
network: Loading proxy configuration from Internet Explorer ...
network: Done.
network: Loading direct proxy configuration ...
network: Done.
network: Proxy Configuration: No proxy


----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
p:   reload proxy configuration
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

liveconnect: Invoking JS method: document
liveconnect: Invoking JS method: URL
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@a0dcd9, refcount=1
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@21b6d
basic: Loading applet ...
network: Connecting http://localhost/WebServerRoot/SimpleLiveConnectApplet2.class with proxy=DIRECT
network: Connecting http://localhost/WebServerRoot/SimpleLiveConnectApplet2/class.class with proxy=DIRECT
load: class SimpleLiveConnectApplet2.class not found.
java.lang.ClassNotFoundException: SimpleLiveConnectApplet2.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: SimpleLiveConnectApplet2.class
java.lang.ClassNotFoundException: SimpleLiveConnectApplet2.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: Joining applet thread ...
basic: Joined applet thread ...
basic: Finding information ...
basic: Releasing classloader: sun.plugin.ClassLoaderInfo@a0dcd9, refcount=0
basic: Caching classloader: sun.plugin.ClassLoaderInfo@a0dcd9
basic: Current classloader cache size: 1
basic: Done ...
basic: Quiting applet ...
liveconnect: Invoking JS method: document
liveconnect: Invoking JS method: URL
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@a0dcd9, refcount=1
Exception in thread "thread applet-SimpleLiveConnectApplet2.class" java.lang.NullPointerException: component argument pData
	at sun.java2d.windows.GDIRenderer.doFillRect(Native Method)
	at sun.java2d.windows.GDIRenderer.fillRect(Unknown Source)
	at sun.java2d.pipe.ValidatePipe.fillRect(Unknown Source)
	at sun.java2d.SunGraphics2D.fillRect(Unknown Source)
	at sun.plugin.util.GrayBoxPanel.paint(Unknown Source)
	at sun.plugin.util.GrayBoxPainter.paintGrayBox(Unknown Source)
	at sun.plugin.util.GrayBoxPainter.repaintGrayBox(Unknown Source)
	at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
	at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
	at sun.plugin.viewer.LifeCycleManager.destroyAppletPanel(Unknown Source)
	at sun.plugin.viewer.IExplorerPluginObject$3.run(Unknown Source)
java.lang.NullPointerException
	at com.sun.deploy.ui.UIFactory.showErrorDialog(Unknown Source)
	at com.sun.deploy.ui.UIFactory.showExceptionDialog(Unknown Source)
	at com.sun.deploy.ui.UIFactory.showExceptionDialog(Unknown Source)
	at sun.plugin.util.Trace.printException(Unknown Source)
	at sun.plugin.util.Trace.printException(Unknown Source)
	at sun.plugin.util.Trace.printException(Unknown Source)
	at sun.plugin.util.Trace.printException(Unknown Source)
	at sun.plugin.AppletViewer.showAppletException(Unknown Source)
	at sun.applet.AppletPanel.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@152544e
basic: Loading applet ...
basic: Initializing applet ...
basic: Starting applet ...
basic: completed perf rollup
network: Connecting http://localhost/WebServerRoot/simpleLiveConnect.jar with proxy=DIRECT
network: Downloading resource: http://localhost/WebServerRoot/simpleLiveConnect.jar
	Content-Length: 937
	Content-Encoding: null
Dump thread list ...
Group main,ac=11,agc=2,pri=10
    main,5,alive
    AWT-Shutdown,5,alive
    AWT-Windows,6,alive,daemon
    traceMsgQueueThread,5,alive,daemon
    AWT-EventQueue-0,6,alive
Group Plugin Thread Group,ac=4,agc=0,pri=10
    AWT-EventQueue-1,6,alive
    ConsoleWriterThread,6,alive,daemon
    TimerQueue,5,alive,daemon
    SysExecutionThead,4,alive
Group http://localhost/WebServerRoot/-threadGroup,ac=2,agc=0,pri=4
    AWT-EventQueue-3,4,alive
    thread applet-SimpleLiveConnectApplet2.class,4,alive
Done.



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
**************************
Simple test applet
**************************

import java.applet.*;
import java.net.*;

public class SimpleLiveConnectApplet2 extends Applet
{
	public void sc(Object a, Object b, Object c, Object d, Object e, Object f, Object g, Object h, Object i, Object j, Object k, Object l, Object m, Object n)
	{
		String stringVal = (String)a;
		String toStringVal = b.toString();
		int intVal = ((Number) c).intValue();
		long longVal = ((Number)d).longValue();
		String string5 = e.toString();
		String string6 = (String)f;
		String string7 = g.toString();
		String string8 =(String)h;
		String string9 = i.toString();
		String string10 =(String)j;
		String string11 = k.toString();
		String string12 =(String)l;
		String string13 = m.toString();
		String string14 =(String)n;
		
		//System.out.println("Received values- String 1: "+stringVal+"; String 2: "+toStringVal+"; int: "+intVal+"; long:"+longVal);
	}
}


***************************
Test HTML Page:
***************************

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> LiveConnect Test </TITLE>
</HEAD>
<BODY>
<H1>LiveConnect Test</H1>

<!--<APPLET codeBase=http://localhost/WebServerRoot/ height=0 width=0 archive=simpleLiveConnect.jar code=SimpleLiveConnectApplet2.class name=testLiveConnectApplet mayscript></APPLET>-->

<script type='text/javascript'>

function testLiveConnect()
{
	var counter = 0;

	while(counter < 200)
	{
		document.testLiveConnectApplet1.sc('String A '+counter, 'String B '+counter, counter, counter, ''+counter, ''+counter, ''+counter, ''+counter, ''+counter, ''+counter, ''+counter, ''+counter, ''+counter, ''+counter);
		counter++;
	}
}

function detectApplet()
{
	if(document.testLiveConnectApplet1)
		testLiveConnect();
	else
		window.setTimeout('detectApplet();', 100);
}

//DYNAMIC APPLET LOADING SECTION

var appletDiv = document.createElement('DIV');
appletDiv.id = 'appletDiv';
appletDiv.setAttribute('style','position:absolute;width:0;height:0;overflow:hidden');
document.body.appendChild(appletDiv);

appletDiv.innerHTML= '<APPLET codeBase=http://localhost/WebServerRoot/ height=0 width=0 archive=simpleLiveConnect.jar code=SimpleLiveConnectApplet2.class name=testLiveConnectApplet mayscript></APPLET>';

// END DYNAMIC APPLET LOADING SECTION

detectApplet();

</script>
</BODY>
</HTML>

</BODY>
</HTML>

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
This bug does not occur when the next generation Java-Plugin is enabled in the Java Control Panel

Comments
EVALUATION This has been fixed very likely under 6639429 in 6u10 build 10, but is certainly working at this point -- this has been confirmed by the customer with a more recent build. Please re-test with build 11 (which is currently available on http://jdk6.dev.java.net/6uNea.html) and re-open this bug if the problem still appears to be there.
28-01-2008