JDK-4129481 : java.lang.ExceptionInInitializerError is occured in JApplet.setLayout()
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1998-04-16
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
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.
Other
1.2.0 1.2beta4Fixed
Description
I found java.lang.ExceptionInInitializerError was occured in JApplet.setLayout()
, when I run a applet extended JApplet.
The CODEBASE parameter in APPLET tag seems wrong, because the same applet
worked fine when I removed CODEBASE parameter.  
Same exception was occured when I used ARCHIVE parameter in APPLET tag.

-----
gotzman{jun}93% javac -d classes JAppletTest.java
gotzman{jun}94% appletviewer test.html
java.lang.ExceptionInInitializerError
        at java.awt.swing.JApplet.setLayout(JApplet.java:247)
        at java.awt.swing.JApplet.<init>(JApplet.java:97)
        at JAppletTest.<init>(JAppletTest.java:5)
        at java.lang.Class.newInstance(Native Method)
        at sun.applet.AppletPanel.createApplet(AppletPanel.java:459)
        at sun.applet.AppletPanel.runLoader(AppletPanel.java:395)
        at sun.applet.AppletPanel.run(AppletPanel.java:234)
        at java.lang.Thread.run(Thread.java:490)

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.2beta4 FIXED IN: 1.2beta4 INTEGRATED IN: 1.2beta4
14-06-2004

EVALUATION hans.muller@Eng 1998-05-06 The problem, which was rather painful to pin down, was a hack added for Java2D for beta3. A static clause was added to JComponent: static { // REMIND: Kludge for JDK1.2beta3 -- use offscreen metrics // BETA3HACK System.setProperty("java2d.offfm", "true"); } Apparently the Makefiles remove the comment. You can see the problem by changing the test applet like this: /* <applet code=JAppletTest codebase=classes width=400 height=400> </applet> */ import java.awt.swing.JApplet; import java.awt.swing.JRootPane; import java.awt.swing.UIManager; public class JAppletTest extends JApplet { protected JRootPane createRootPane() { try { return super.createRootPane(); } catch (ExceptionInInitializerError e) { System.out.println("Exception raised in JApplet.createRootPane(): " + e); e.getException().printStackTrace(); throw e; } } } AppletViewer does a poor job of handling ExceptionInInitializer errors by default. By catching the exception in createRootPane, we can see (sort of) where the culprit is: Exception raised in JApplet.createRootPane(): java.lang.ExceptionInInitializerError java.security.AccessControlException: access denied (java.util.PropertyPermission java2d.offfm write) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:155) at java.security.AccessController.checkPermission(AccessController.java:279) at java.lang.SecurityManager.checkPermission(SecurityManager.java:453) at java.lang.System.setProperty(System.java:502) at at at JAppletTest.createRootPane(JAppletTest.java:24) at java.awt.swing.JApplet.<init>(JApplet.java:97) at JAppletTest.<init>(JAppletTest.java:13) at java.lang.Class.newInstance(Native Method) at sun.applet.AppletPanel.createApplet(AppletPanel.java:459) at sun.applet.AppletPanel.runLoader(AppletPanel.java:395) at sun.applet.AppletPanel.run(AppletPanel.java:234) at java.lang.Thread.run(Thread.java:490) java.lang.ExceptionInInitializerError at at JAppletTest.createRootPane(JAppletTest.java:24) at java.awt.swing.JApplet.<init>(JApplet.java:97) at JAppletTest.<init>(JAppletTest.java:13) at java.lang.Class.newInstance(Native Method) at sun.applet.AppletPanel.createApplet(AppletPanel.java:459) at sun.applet.AppletPanel.runLoader(AppletPanel.java:395) at sun.applet.AppletPanel.run(AppletPanel.java:234) at java.lang.Thread.run(Thread.java:490) Clearly the Java2D hack only works for applications - it sets a system property. As the submitter pointed out, this hack tubes Swing applets. There's no workaround that I know of.
11-06-2004

WORK AROUND Don't use CODEBASE or ARCHIVE tag in APPLET tag.
11-06-2004