United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6888527 NoClassDefFoundError when loading class without cache in applet
JDK-6888527 : NoClassDefFoundError when loading class without cache in applet

Details
Type:
Bug
Submit Date:
2009-10-06
Status:
Closed
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2009-10-22
Component:
deploy
OS:
windows_xp
Sub-Component:
plugin
CPU:
x86
Priority:
P3
Resolution:
Cannot Reproduce
Affected Versions:
6u10
Fixed Versions:

Related Reports
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_18-ea"
Java(TM) SE Runtime Environment (build 1.6.0_18-ea-b02)
Java HotSpot(TM) Client VM (build 16.0-b09, mixed mode, sharing)

But also fails with 1.6.0_15 and higher versions.
1.6.0_14 works properly

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [verzi??sz??m: 5.1.2600] with SP3

EXTRA RELEVANT SYSTEM CONFIGURATION :
Browsers:
Mozilla/5.0 (Windows; U; Windows NT 5.1; hu; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)
Internet Explorer: 8.0.6001.18702

Web server:
Server version: Apache/2.2.11 (Win32)
Server built:   Dec 10 2008 00:10:06

Ant:
Apache Ant version 1.7.1


A DESCRIPTION OF THE PROBLEM :
If the Java cache is disabled and the applet has signed jars a NoClassDefFoundError is thrown when applet tries to load an other class from the same package if the class which has to be loaded is in an another jar. With unsigned jars this problem not exists.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Start browser
Load a page whit the applet
Error thrown.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Applet should start properly
ACTUAL -
Applet fails to start.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Java Plug-in 1.6.0_18
Using JRE version 1.6.0_18-ea-b02 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Rendszergazda


security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws
security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy
security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.definition value null
security: property package.definition new value com.sun.javaws
security: property package.definition value com.sun.javaws
security: property package.definition new value com.sun.javaws,com.sun.deploy
security: property package.definition value com.sun.javaws,com.sun.deploy
security: property package.definition new value com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
security: property package.definition value com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.definition new value com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@19616c7
network: Connecting http://locdomain.local/test/test.jar with proxy=DIRECT
network: Connecting http://locdomain.local:80/ with proxy=DIRECT
network: Downloading resource: http://locdomain.local/test/test.jar
	Content-Length: 2??756
	Content-Encoding: null
security: Blacklist revocation check is enabled
security: The jar file isnt on a blacklist
security: Accessing keys and certificate in Mozilla user profile: null
security: Loading Root CA certificates from C:\Program Files\Java\jre6\lib\security\cacerts
security: Loaded Root CA certificates from C:\Program Files\Java\jre6\lib\security\cacerts
security: Loading Deployment certificates from C:\Documents and Settings\Rendszergazda\Application Data\Sun\Java\Deployment\security\trusted.certs
security: Loaded Deployment certificates from C:\Documents and Settings\Rendszergazda\Application Data\Sun\Java\Deployment\security\trusted.certs
security: Loading certificates from Deployment session certificate store
security: Loaded certificates from Deployment session certificate store
security: Validate the certificate chain using CertPath API
security: Obtain certificate collection in Root CA certificate store
security: Obtain certificate collection in Root CA certificate store
security: No timestamping info available
security: Found jurisdiction list file
security: No need to checking trusted extension for this certificate
security: The CRL support is disabled
security: The OCSP support is disabled
security: Checking if certificate is in Deployment denied certificate store
security: Checking if certificate is in Deployment permanent certificate store
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 174111 us, pluginInit dt 1608881 us, TotalTime: 1782992 us
basic: Applet initialized
basic: Removed progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@19616c7
basic: Applet made visible
basic: Starting applet
basic: completed perf rollup
network: Connecting http://locdomain.local/test/foo.jar with proxy=DIRECT
network: Downloading resource: http://locdomain.local/test/foo.jar
	Content-Length: 1??967
	Content-Encoding: null
security: The jar file isnt on a blacklist
network: Connecting http://locdomain.local/test/Foo.class with proxy=DIRECT
Exception in thread "thread applet-TestApplet-1" java.lang.NoClassDefFoundError: Foo
	at TestApplet.start(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Foo
	at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 3 more
Caused by: java.io.IOException: open HTTP connection failed:http://locdomain.local/test/Foo.class
	at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	... 6 more

Apache log:
127.0.0.1 - - [24/Sep/2009:12:47:12 +0200] "GET /test HTTP/1.1" 301 324
127.0.0.1 - - [24/Sep/2009:12:47:12 +0200] "GET /test/ HTTP/1.1" 200 1187
127.0.0.1 - - [24/Sep/2009:12:47:14 +0200] "GET /test/test.jar HTTP/1.1" 200 2756
127.0.0.1 - - [24/Sep/2009:12:47:14 +0200] "GET /test/foo.jar HTTP/1.1" 200 1967
[Thu Sep 24 12:47:14 2009] [error] [client 127.0.0.1] File does not exist: C:/test/Foo.class
127.0.0.1 - - [24/Sep/2009:12:47:14 +0200] "GET /test/Foo.class HTTP/1.1" 404 1075


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
TestApplet:

import javax.swing.JApplet;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class TestApplet extends JApplet {

    private static final long serialVersionUID = -8222760725492315060L;

    public void init() {
	SwingUtilities.invokeLater(new Runnable() {
	    public void run() {
		createGUI();
	    }
	});
    }

    private void createGUI() {
	JPanel panel = new JPanel();
	panel.add(new JLabel("testApplet"));

	getContentPane().add(panel);
    }

    public void start() {
	Foo f = new Foo();
    }

    public void stop() {
    }

    public void destroy() {
    }
}

Foo:

public class Foo {
}


build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="applettest" default="javac" basedir=".">

	<target name="javac" description="Creates java classes.">
		<mkdir dir="bin" />
		<javac srcdir="." destdir="bin" />
	</target>

	<target name="release" depends="clean, javac" description="Create jar files to ./release">
		<mkdir dir="release" />
		<jar jarfile="release/foo.jar" includes="Foo.class" basedir="bin" />
		<jar jarfile="release/test.jar" includes="TestApplet.class TestApplet$1.class" basedir="bin">
			<manifest>
				<attribute name="Class-Path" value="foo.jar" />
			</manifest>
		</jar>
	</target>

	<target name="release.sign" description="Create jar signed jar files to ./release" depends="release">
		<signjar jar="release/test.jar" alias="testkey" storepass="testpass" signedjar="release/test.jar"
			keystore="testkeystore" />
		<signjar jar="release/foo.jar" alias="testkey" storepass="testpass" signedjar="release/foo.jar"
			keystore="testkeystore" />
	</target>

	<target name="clean" description="Cleans all output folder.">
		<delete dir="bin" />
		<delete dir="release" />
	</target>

</project>

Build with release.sign target. testkeystore needed with a testkey which has testpass, or other keystores are useable after editing build.xml.
The whole code are available with testkeystrore at: http://csomalin.csoma.elte.hu/~pifta/test.zip
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Turn on the cache partly resolve the problem.
If the cache is enabled, and only one of the jars is in the cache, and the applet triggers the other class to load for a user event, the error still exsits. I have reported this problem separately with more details.

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

                                    

Comments
EVALUATION

Please refer to the evaluation in 6888528.
                                     
2009-10-22



Hardware and Software, Engineered to Work Together