applet fails to load with nullpointerexception

Bug #199732 reported by Timothy G. Rundle on 2008-03-08
Affects Status Importance Assigned to Milestone
Fix Released
icedtea-gcjwebplugin (Ubuntu)
Declined for Intrepid by Matthias Klose
openjdk-6 (Fedora)
Fix Released
openjdk-6 (Ubuntu)
Declined for Intrepid by Matthias Klose

Bug Description

Binary package hint: icedtea-java7-plugin

I am trying to access an applet from The applet fails to load with error:

Exception in thread "main" java.lang.NullPointerException
 at sun.applet.PluginMain.start(
 at sun.applet.PluginMain.main(

I am running Hardy Alpha 6 (firefox3, icedtea-java7). The applet works just fine on my Gutsy box (firefox2, sun6).

I have attached the complete console output

ProblemType: Bug
Architecture: i386
Date: Fri Mar 7 23:13:26 2008
DistroRelease: Ubuntu 8.04
Package: firefox 3.0~b3+nobinonly-0ubuntu4
PackageArchitecture: all
SourcePackage: firefox-3.0
Uname: Linux 2.6.24-11-generic i686

Timothy G. Rundle (tgrundle) wrote :
Matti Lindell (mlind) wrote :

Can you reproduce this after uninstalling all icedtea-java7 packages and then installing icedtea-gcjwebplugin package ? icedtea-java7 has been removed from the archive and replaced by openjdk-6.

Changed in icedtea-java7:
status: New → Incomplete

No luck Matti. Got the same error. Also as an FYI, after making the switch
I had to manually run 'sudo update-alternatives --auto java'


Matti Lindell (mlind) wrote :

I can confirm this, using icedtea-gcjwebplugin 1.0-0ubuntu3. Applets in the site seem to work fine with sun-java6-plugin though.

Changed in icedtea-java7:
importance: Undecided → Medium
status: Incomplete → Confirmed
Timothy G. Rundle (tgrundle) wrote :

I finally got some more free time to look at this issue and it turns out that technically this is not a bug. The website is not setting the height and width attributes on the applet tag. Below is the actual applet tag definition. The fact still remains that the sun plugin works, which means they are more forgiving when it comes to the specs.

<applet archive="/pzj/jz.jar" codebase="/pzj/" code="jz.class" id="Z" name="Z" mayscript ><param name="v" value="131;1;67 Piece Classic;jz/jzG/Boat_Optimist;;;;;WWHFX7;"><param name="t" value="87JYOEGM.90002771.1.84.228512.604_0_0__4A"><param name="u" value="mozilla/5.0 (x11; u; linux i686; en-us; rv:1.9b5) gecko/2008041514 firefox/3.0b5"></applet>

Timothy G. Rundle (tgrundle) wrote :

I created a patch to get past the NPE exception, basically set a default width and height of 1 if none is present in the tag. I wasn't able to confirm that this applet works since it requires LiveConnect, but I get past the original exception

adamski (adam-jigzone) wrote :

I am the author of

The default height and width of the applet are set in the CSS style sheet


I'm not sure if this is technically incorrect, but it works on all of the wide variety of OS/browser combinations I have tested for.

robogeek (david-herron-sun) wrote :

My system never had icedtea-7 installed and it runs the thing fine (I assume "the Jigzone applet" means any of the jigsaw puzzles on that site...?). But testing which java version is being executed for applets it appears that the java alternative is ignored. I have java-1.5.0-sun, java-6-sun and java-6-openjdk installed along with firefox 3.0b5. No matter what the setting of the current java alternative using the test applet at it shows that the 6u6 plugin is being used.

Timothy G. Rundle (tgrundle) wrote :

   I am not sure either if setting the height and width for an applet in a stylesheet is correct. A brief read of section 17.3 of the HTML 4.01 spec ( does seem to clear it up for me. Although I would lean towards saying that the height and width should be set on the tag and not in the stylesheet given the fact that all other attributes that are support via stylesheet are marked depricated.
  If setting the height and width in the stylesheet is valid, there still is the issue of accessing that information in the plugin. I did not see anyway the plugin could resolve the stylesheet settings. My C programming is not strong and I am not familiar with Mozilla plugin programming so I may have missed something.
  When I get a free moment I will write a test applet to see how the sun plugin reacts to having the height and width in a stylesheet verses not being set at all

Սահակ (petrosyan) wrote :

I can confirm this bug on Ubuntu 8.04 64 bit.

When I go to site I get the following error:
  PIPE: appletviewer read: instance-9780-0
  PIPE: appletviewer read: width 400
Exception in thread "main" java.lang.NullPointerException
 at sun.applet.PluginMain.start(
 at sun.applet.PluginMain.main(
GCJ PLUGIN: thread 0x6228e0: plugin_out_pipe_callback
GCJ PLUGIN: thread 0x6228e0: plugin_out_pipe_callback: appletviewer has stopped.
GCJ PLUGIN: thread 0x6228e0: plugin_out_pipe_callback return
GCJ PLUGIN: thread 0x6228e0: plugin_in_pipe_callback
GCJ PLUGIN: thread 0x6228e0: appletviewer has stopped.
GCJ PLUGIN: thread 0x6228e0: plugin_in_pipe_callback return

and just an empty grey box.

Changed in openjdk-6:
status: Unknown → Confirmed

I get the same error in Ubuntu 8.04.1 (64-bit) when trying to view either or which are just two of the online interactive bus route maps in the United Kingdom. It's supposed to display a navigable map, but all I get is a grey box where the map should be.

Console Error is:

  PIPE: appletviewer read: instance-8990-3
  PIPE: appletviewer read: width 418
Exception in thread "main" java.lang.NullPointerException
 at sun.applet.PluginMain.start(
 at sun.applet.PluginMain.main(
GCJ PLUGIN: thread 0x622950: plugin_out_pipe_callback
GCJ PLUGIN: thread 0x622950: plugin_out_pipe_callback: appletviewer has stopped.
GCJ PLUGIN: thread 0x622950: plugin_out_pipe_callback return
GCJ PLUGIN: thread 0x622950: plugin_in_pipe_callback
GCJ PLUGIN: thread 0x622950: appletviewer has stopped.
GCJ PLUGIN: thread 0x622950: plugin_in_pipe_callback return

TJ (tj) wrote :

This bug is caused when the Java plugin hasn't had a window registered using PluginMain.registerWindow(), which will set PluginMain.currentWindow.

Without PluginMain.currentWindow set (it is initialised to null), when the gcjwebplugin sends the applet the "width" message, the applet's PluginMain.start() message-reading loop reads the width correctly, but then tries to get the internal height property using:

int height = currentWindow.getHeight();

Because currentWindow is NULL it causes the Null Pointer Exception on line 211.

The problem is caused in PluginAppletViewer.parse(...). There are several overloaded versions of this function but they all pass through to the work-horse overload that takes a complete set of arguments.

In PluginAppletViewer.parse() it scans the HTML APPLET/OBJECT/EMBED tag and extracts the attribute values. When it finds an EMBED tag it passes it to PluginAppletViewer.scanTag(). That method is responsible for scanning the parameters inside the <EMBED> tag and assigning them to internal attributes.

When scanTag() returns the EMBED detection-logic does some sanity checks on the attributes to ensure it has what it needs to execute the applet successfully. It checks for the CODE, WIDTH, and HEIGHT attributes not being null. If any one of them is null it sets the attribute reference to null too - effectively wiping them all out.

When the logic in PluginAppletViewer.parse() finds the closing tag </EMBED> it checks if the attributes reference IS NOT null and if so calls PluginAppletViewerFactory.createAppletViewer(). That in turn calls PluginMain.registerWindow() which, as I said at the beginning, sets PluginMain.currentWindow.

But, because an attribute of the EMBED tag was missing, the attribute reference was null and so PluginMain.registerWindow() wasn't called and PluginMain.currentWindow remained with its initialised value, which is null.

Hence the bug.

In the case of the sites here the missing tag is CODE, and you can see the warning in the output:

Warning: <embed> tag requires code attribute.

That really should say "Error" since it is fatal.

Because the EMBED tag was not part of a W3C standard the definition of legal parameters is hazy. It has been introduced for HTML 5 *but* will not support the CODE attribute.

Changed in openjdk-6:
assignee: nobody → intuitivenipple
importance: Undecided → Medium
status: New → Confirmed
TJ (tj) on 2008-09-01
Changed in icedtea-gcjwebplugin:
importance: Medium → Low
status: Confirmed → Invalid
TJ (tj) wrote :

I've created a patch that fixes this issue. Tested against a site which would previously fail due to no CODE attribute:

GCJ PLUGIN: thread 0x6229b0: plugin_in_pipe_callback return
  PIPE: appletviewer wrote: status starting applet...
  PIPE: appletviewer read: instance-15261-5
  PIPE: appletviewer read: width 625
  PIPE: appletviewer read: instance-15261-5
  PIPE: appletviewer read: height 875
Jar string: mortgage-en.jar
jars length: 1
initializing JNLPRuntime...
  PIPE: appletviewer wrote: status Applet loaded.

Timothy's reported applets on jigzone,com still fail since they don't have a WIDTH or HEIGHT attribute specified.

GCJ PLUGIN: thread 0x6229b0: GCJ_SetWindow return
Warning: <embed> tag requires width attribute.

The Bus route planning applets reported by HappySpaceInvader still fail, but not because of the tag. They fail due to Javascript support exceptions:

** ACIS Live v2.1 - jBusMapEngine v4.3
** Author: Robert Tinsley
** Email: <email address hidden>

  PIPE: appletviewer wrote: status error: java.lang.NoClassDefFoundError: netscape/javascript/JSObject.
java.lang.NoClassDefFoundError: netscape/javascript/JSObject
 at BusMap.init(
Caused by: java.lang.ClassNotFoundException: netscape.javascript.JSObject
 at net.sourceforge.jnlp.runtime.JNLPClassLoader.loadClassExt(
 at net.sourceforge.jnlp.runtime.JNLPClassLoader.loadClass(
 at java.lang.ClassLoader.loadClassInternal(
 ... 3 more
  PIPE: appletviewer wrote: status Start: applet not initialized.

Download full text (6.3 KiB)

This is an upstream report based on Ubuntu Bug LP #199732

== Overview ==

Loading some Java applets via Firefox and the plugin with openjdk-6 results in:

Exception in thread "main" java.lang.NullPointerException
 at sun.applet.PluginMain.start(
 at sun.applet.PluginMain.main(

See, for example:

I'll detail the analysis and the fix after this explanation.

== Background ==

There are an unknown number of Internet sites hosting Java applets that fail when using the icedtea plug-in but work using the Sun Java plug-in. The reason for the failure is usually a result of the historic mess that was made of the HTML EMBED, APPLET, and OBJECT tags.

As a result of the various contrived work-arounds that web-site authors used to try and ensure that all browsers managed to load a Java applet, there are many combinations of these tags and the PARAM name/value attribute tags that attempt to use browser quirks to ensure the user does see the Java applet.

There has never been a standard for the EMBED tag particularly, it having grown over time from its beginnings in Netscape Navigator. There have likewise been various unofficial extensions to the OBJECT tag - the only properly standardised tag - which should really replace the other two tags in modern browsers and web-applications.

As a result users often suffer, caught between a rock and a hard place when things go wrong - such as this NullPointerException - since they have no influence over the web-site operators in most cases, and often get told by developers that it is the web-site's problem, not the plug-in, despite the widespread use of varying combinations of browser-specific tag combinations. (See, for example, the responses in Bug #151).

== The Issue ==

In the cases I've dealt with the failures are caused by the use of the EMBED tag with no "code" attribute.

However, the HTML author has attempted to ensure all browsers/Java plug-ins load the applet by including OBJECT and/or APPLET variations as well as using PARAM name/value pairs.

The plug-in currently refuses to accept a tag-set passed by the browser plug-in *before it has been completely parsed* if the initial tag isn't of the form:


It will also then ignore any PARAM name/value pairs as being "outside an APPLET tag". This is unfortunate since in many cases the PARAM pairs contain values that the plug-in can use to load the applet successfully.

== The Solution ==

The patch I've created refines the way PluginAppletViewer.parse() deals with the EMBED tag. It adopts the same logic as is already present for the OBJECT tag, deferring rejection of the attributes until the closing tag, and thus allowing any PARAM name/value pairs after the opening tag to be parsed into the attributes Hash.

When the closing EMBED tag is parsed, if there is still no "code" or "object" attribute, the patch makes one last attempt to locate the entry-point class. It first looks for the attribute "classid". If it is found, the patch further chec...


Created attachment 90
Defer EMBED attribute decision; accept wider range of OBJECT/EMBED/APPLET attribute permutations

Changed in openjdk:
status: Unknown → Confirmed
TJ (tj) wrote :

Test package is now available from my PPA:

openjdk-6 (6b11-2ubuntu3~ppa1h) hardy; urgency=low

  * PluginAppletViewer: accept PARAM tags inside EMBED and try to translate
    "classid" to "code" so appletviewer has a start-up class, before deciding
    to nullify all attributes. LP #199732

 -- TJ <email address hidden> Mon, 1 Sep 2008 06:00:00 +0100

TJ (tj) wrote :

Deepak, you probably want to look into this one.

Thelasko (stever530) wrote :

TJ's fix allows the following pages to run:

The following pages don't run:
or the Facebook photo uploader

Thelasko (stever530) wrote :
TJ (tj) wrote :

The listed URLs that don't run fail due to the gcjplugin not supporting Javascript LiveConnect. Work is in progress upstream with the IcedTea plugin to solve this, and the current test code is doing well.

I don't use Facebook so I can't test. Please start firefox from the command-line, visit Facebook and try running the applet, and then atttach here the logged output with the exceptions so we can determine what the cause of the failure is.

Timothy G. Rundle (tgrundle) wrote :

  It seems like TJ's fix corrects and existing bug, but don't not address the original bug report from what i can tell. I believe Matti and I came to the conclusion that the rrot cause was that the missing height and width on the page wasn't valid, but since the sun plugin handles the tag, the icedtea-gcjwebplugin should as well.

I am not clear on why the icedtea-gcjwebplugin association was marked as invalid nor why the patch i submitted hasn't be considered.

TJ (tj) wrote :

Timothy, my apologies, I had meant to mark the icedtea-gcjplugin as "Won't Fix" on the basis that all work upstream is now focused on the new IcedTea Plug-in which will be available soon. Corrected it now. IcedTea Plug-in will solve the applet parameter and Javascript LiveConnect issues too.

Changed in icedtea-gcjwebplugin:
status: Invalid → Won't Fix

Just for the record, item has been fixed in the IcedTea plugin. I will get to the GCJ plugin shortly. now works with the IcedTeaPlugin. still fails, but the problem appears to be in the applet itself:

Exception in thread "Thread-11" java.lang.NullPointerException

Timothy G. Rundle (tgrundle) wrote :

I think this bug can be closed. The icedtea6-plugin ( 6b12~pre1-0ubuntu5 ) seems to address the NullPointerException issue. The site still doesn't work, but the problem now seems to be with LiveConnect, see attached log. I believe this is related to Bug # 207064, although the comments there imply LiveConnect was implemented in the latest plugin.

Matthias Klose (doko) wrote :

fixed in openjdk-6 6b12~pre2-0ubuntu2

Changed in openjdk-6:
status: Confirmed → Fix Released
Changed in openjdk-6:
status: Confirmed → In Progress

Both, now works and now work with the new plugin in release 1.3.1+.

Closing issue.

Changed in openjdk:
status: Confirmed → Fix Released
Changed in openjdk-6:
status: In Progress → Fix Released
MANMOHAN (manmohanm89) wrote :

cannot execute applet programs
i can compile java applet programs but i cannot execute applet viewer.

Changed in openjdk:
importance: Unknown → Medium
Changed in openjdk-6 (Fedora):
importance: Unknown → Low
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.