United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-5004298 : Running in Headless mode still produces Headless exception with GTK UI

Details
Type:
Bug
Submit Date:
2004-02-26
Status:
Closed
Updated Date:
2010-07-09
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
client-libs
OS:
linux,solaris_9
Sub-Component:
javax.swing
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
8.0pe,1.4.2
Fixed Versions:

Related Reports

Sub Tasks

Description
Name: rmT116609			Date: 02/26/2004


FULL PRODUCT VERSION :
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux 2.4.20-gentoo-r6

EXTRA RELEVANT SYSTEM CONFIGURATION :
Console only - X has been turned off.

A DESCRIPTION OF THE PROBLEM :
The server is running Java in headless mode, ie,  -Djava.awt.headless=true

Using a JPanel in our image conversion tool attempts to use the GTK look and feel.  Pango then attempts to call sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice(...), which throws a Headless exception.

This should not be the case since the headless=true option was on the command line.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Get a linux server.

Compile the test  case below.

%java -Djava.awt.headless=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel Test

I have a properties file which stipulates that the GTK look and feel should be used for all java apps, and this is why the original command would not work for me.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
For the application to terminate normally.
ACTUAL -
ExceptionInInitializerError is thrown.

See the below stack trace.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ExceptionInInitializerError
     at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.handleParsedData(GTKLookAndFeel.java:353)
     at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.access$100(GTKLookAndFeel.java:23)
     at com.sun.java.swing.plaf.gtk.GTKLookAndFeel$1.run(GTKLookAndFeel.java:270)
     at java.security.AccessController.doPrivileged(Native Method)
     at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStylesFromThemeFiles(GTKLookAndFeel.java:205)
     at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initialize(GTKLookAndFeel.java:181)
     at javax.swing.UIManager.setLookAndFeel(UIManager.java:393)
     at javax.swing.UIManager.setLookAndFeel(UIManager.java:424)
     at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1085)
     at javax.swing.UIManager.initialize(UIManager.java:1181)
     at javax.swing.UIManager.maybeInitialize(UIManager.java:1164)
     at javax.swing.UIManager.getUI(UIManager.java:775)
     at javax.swing.JPanel.updateUI(JPanel.java:104)
     at javax.swing.JPanel.<init>(JPanel.java:64)
     at javax.swing.JPanel.<init>(JPanel.java:87)
     at javax.swing.JPanel.<init>(JPanel.java:95)
     at Test.main(Test.java:8)
Caused by: java.awt.HeadlessException
     at sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice(HeadlessGraphicsEnvironment.java:66)
     at com.sun.java.swing.plaf.gtk.PangoFonts.<clinit>(PangoFonts.java:36)
     ... 17 more

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

import javax.swing.JPanel;

public class Test
{
    public static void main(String[] args)
    {
        JPanel p = new JPanel();
    }
}


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

CUSTOMER SUBMITTED WORKAROUND :
Don't use a JPanel, or run with X turned on!!
(Incident Review ID: 239279) 
======================================================================
###@###.### 11/3/04 18:34 GMT

                                    

Comments
EVALUATION

Contribution-Forum:https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?messageID=11673&forumID=1463
                                     
2006-02-27
EVALUATION

Name: omR10226			Date: 03/02/2004

Not reproducible with 1.5.0-beta-b32.


======================================================================
###@###.### 11/3/04 18:34 GMT
                                     
4-11-03 00:00:00



Hardware and Software, Engineered to Work Together