Accessibility

TechNote (Archived)

Configuring non-graphics-enabled servers with java.awt.headless

Issue


I get the following error when I try to access an MXML page - why?

 Can't connect to X11 window server using ':0.0' as the value of the            DISPLAY variable.     java.lang.InternalError: Can't connect to X11 window server            using ':0.0' as the value of the DISPLAY variable.     at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)     at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:125)     at java.lang.Class.forName0(Native Method)     at java.lang.Class.forName(Class.java:140)at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment            (GraphicsEnvironment.java:62)     at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:72)     at java.lang.Class.forName0(Native Method)     at java.lang.Class.forName(Class.java:140)     at java.awt.Toolkit$2.run(Toolkit.java:712)     ... 

Reason


This is most likely because the server doesn't have a graphical subsystem (i.e. a graphics card and monitor). The Flex server uses Java's AWT (Abstract Window Toolkit) to implement compile time image embedding and SVG. By default, the Java Virtual Machine tries to use the hardware-based graphical capabilities of the machine to implement AWT. For servers without a graphical interface, the above error will be thrown.

Solution


To resolve this issue, set the system propertyjava.awt.headless to true so that the JVM will implement AWT in software, rather than attempting to use non-existent hardware-based graphics.

Note:java.awt.headless is only available with JDK 1.4 and above. It is not available on previous versions of the JDK.

There are two ways to set java.awt.headless to true:

  • Using the command line:

    -Djava.awt.headless=true
  • Configuring in /WEB-INF/flex/flex-config.xml as:
     <compiler><headless-server>true</headless-server></compiler> 
    Note:java.awt.headless should only be set to true if no graphics card exists on your machine. If you set this property to true when a graphics card exists, it will cause the cfchart tag in ColdFusion to throw an error.

If you are using WebSphere on Linux, you must set -Djava.awt.headless=true in the WebSphere administrator. Select Application Servers >your server instance> Process Definition > Java Virtual Machine > Generic JVM arguments, then add the setting.

You may see the following error if it is not set when you request the sample data model:

 sun/awt/motif/MToolkit Technical Information: HTTP Status Code: 500 Exception Type: class java.lang.NoClassDefFoundError Servlet Name: FlexMxmlServlet Exception java.lang.NoClassDefFoundError  sun/awt/motif/MToolkit (View stack trace)Actual Results: HTTP Status Code: 500Exception Type: class java.lang.NoClassDefFoundError Servlet Name: FlexMxmlServlet 

After you restart your server, the sample should work. If you still see the error, delete all your temporary internet files so that your browser is not serving up the cached page.

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support


Document Details

ID:tn_19252
Browser:Chrome
Internet Explorer
Netscape
Opera
Safari
Firefox

Products Affected:

flex