Skip to main content

NoClassDefFoundError in Applet since Java 1.6.0_15

8 replies [Last post]
budde
Offline
Joined: 2009-09-15
Points: 0

Hi all,

I have a problem with a signed Java applet that is started using the tag from HTML.
The JAR is built on Java 1.4.2 (but no difference building it on 1.6.0_16) and is run under 1.6.0_16 and it adds other JARs to the classpath in its manifest (but the class that is not found is in the 'primary' JAR).
The applet is run in InternetExplorer 6.0.2900.2180.xpsp_sp2_gdr.070227-2254.

Since I installed the new JRE (1.6.0_16) with Java plugin, a NoClassDefFoundError is thrown when accessing a static method on a class importing the class that cannot be found.

It looks like this:
Exception in thread "thread applet-MyApplet.class-1" java.lang.NoClassDefFoundError: my/package/MyClass1
at my.package.MyClass1.initStage5(MyClass1.java:483)
at my.package.MyClass1.init(MyClass1.java:147)
at my.package.MyClass1.init(MyClass2.java:80)
at MyClass3.init(MyClass3.java:42)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: my.package.MyClass1
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 6 more

Before adding the parameter this ClassNotFoundException was caused my a further FileNotFoundException... I'm not sure what that is supposed to mean.

Turning off the "next-generation Java Plug-in" functionality in the Java control Panel (Advanced) it works fine, but this seems to be no option for other reasons.

Does anybody know of an option that might be related to this?

Many thanks in advance,
Stefan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
seboooo
Offline
Joined: 2009-10-05
Points: 0

Hi,
I have exactly the same problem as You've described as "second case". Have You already found any solution?

Thanks for any help.

Seboo

Message was edited by: seboooo

pifta
Offline
Joined: 2009-09-22
Points: 0

No unfortunately i haven't have more information about the issue, i've posted a bug report to Sun, and waiting for their reply. The bug report is in internal review state for one and a half week now.

ndcosta123
Offline
Joined: 2007-10-03
Points: 0

Hi Pifta,

We have included your bug reports in our bug database with id's - 6888527 and 6888528. This will be visible in a couple of days at -
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6888527
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6888528

Thanks,
Nelson

tuler
Offline
Joined: 2006-05-27
Points: 0

I also have the second problem. Unfortunetly the bug has been closed as "Not Reproducible" :-(
Please reopen it!

ccng123
Offline
Joined: 2010-01-20
Points: 0

Yeah, I have the exact problem in my Applet.
I checked and double checked my classpath
and couldn't fond any clue!

sailor2010
Offline
Joined: 2010-02-18
Points: 0

I have a similar problem. My applet fails w/the NCDFE when it trys to reference a static class method located in a different package, though it the same jar as the calling applet. I haven't checked the cache yet. I noticed that the manifest after signing the jar has numerous project classes, yet quite a few from the project are missing including the class causing the NCDFE error. Is there a reason why these class references are generated after signing, yet some do not? Could this be part of the problem?

pifta
Offline
Joined: 2009-09-22
Points: 0

Hi,
I'm facing this problem too. I have some results and thoughts about the root of the problem, but it is absolutely not sure yet.

In Java 1.6.0_15 there were some changes in the plugin2 engine in relation to cache handling.
I have found two specific case which can cause such a NoClassDefFoundError.

First case:
Use Class.forName() to load a class from the default package cause NCDFE because the classloder tries to find the class file on the server not in the jar which has been downloaded correctly. This behavior came up when client side Java cache was completely disabled and the jars were signed. I decided to make some further debugging before submit this as a bug, but i don't have enough time to do so until now.

Second case:
Appears with signed jars when applet code has a package which contents are separated into two or more jars, and applet uses Class.forName to load classes from that package. If applet runs for the first time, with clean cache(or with such a cache that contains nothing related to the applet which is loading and running at the moment) everything works fine, every classes and jars loaded correctly. After that with applet related jars in the cache(restart browser and load the applet again), when applet is trying to load a class with Class.forName - from a package which has formerly cached pieces in the java cache - the jar is downloaded, but the classloader is not able to load the class from the just downloaded jar. Then classloader tries to download the class file directly from the server and throw a NCDFE because only the jar files are on the server. It seems the package-jar relations not updated in time inside the cache mechanism of plugin2, and the classloader cannot search the newly downloaded jar files for classes - in such a package which has downloaded parts in the formerly cached jar files. Of course i didn't have enough time to deeply debug this issue as the previous one.

I'm submitting somewhere the created minimal reproduction cases and give a link for that. If somebody has time, every idea and further investigations are welcome...:)

Pifta

pifta
Offline
Joined: 2009-09-22
Points: 0

Test cases:
First case: http://csomalin.csoma.elte.hu/~pifta/test.zip
Second case: http://csomalin.csoma.elte.hu/~pifta/test2.zip

Info for test.zip usage:
Use a webserver to view index.html after building applets with release.sign target. Error will be thrown while initializing the applet if java cache is disabled.

Info for test2.zip useage:
Use webserver to view index.html.
Build applets with release target and after that launch release.sign target.
Open the java control panel.
Clear the cache.
Load index.html into a browser(i've used firefox 3.0 on winxp sp3)
Close browser.
Open the browser again.
Load index.html
Click on the button inside the applet.
Error will be thrown.

Please let me know if i screwed up somthing, and that cause the problem...:)

Pifta

Message was edited by: pifta