[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment

Posted on 2007-10-09
Medium Priority
Last Modified: 2013-11-24
I'm using NetBeans 5.5.1 IDE with Visual Web Pack. My OS is Linux Fedora Core 6 and the server is Sun Java System Application Server.
I'm developing an application which includes a JSP to display a bar-chart graph using CeWolf.
I get the following two severe errors on running the JSP:

1.  Message ID: StandardWrapperValve[CewolfServlet]
Servlet.service() for servlet CewolfServlet threw exception
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
at java.lang.Class.forName0(Native Method)

2.Message ID: CewolfServlet
Could not initialize class sun.awt.X11GraphicsEnvironment
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:169)
      at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
      at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:89)
 I'd appreciate your kind guidance in solving this problem    
Question by:Rrugemalira
  • 2
  • 2
LVL 20

Expert Comment

ID: 20042549
Do you have a X11 server daemon running on the server? Because this class is using native codes which on Unix need X11.
The other option would be to use PJA Toolkit (http://www.eteks.com/pja/en/) instead of the standard AWT

Although... which JDK you use? For 1.4.2+,  it may be enough to use java.awt.headless=true
setProperty( "java.awt.headless", true ); in the code or as a start parameter.

Author Comment

ID: 20043400
I'm using jdk1.6.0_02
The system monitor shows I have Xorg sleeping but consuming CPU. Moreover, I'm working in graphics mode with the netbeans IDE and I can see some graphics on the JSP pages when my application is running (except for the chart component)
You will forgive my ignorance, but I do now know where to setProperty("java.awt.headless", true)
In which code do I set it? In the jsp that renders the chart? In the bean that implements the dataset producer?
LVL 20

Accepted Solution

Venabili earned 1200 total points
ID: 20043434
Honesly - I do not remember.. Haven't touched AWT from years. I would try with the bean.

The error is definitely claiming that there is no X server.
LVL 28

Assisted Solution

rrz earned 300 total points
ID: 20045588
System.setProperty("java.awt.headless", "true");
aslo see

Author Comment

ID: 20051636
I entered into Sun Java System Application Server Administration Console
Clicked on:
Application Server --> JVM Settings --> JVM Options
and added the JVM option: -Djava.awt.headless=true
Stopped the server and re-started it.
I'm now able to display the bar-chart graphics. Praise be to God!
I thank all of you for your kind help.

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
What You Need to Know when Searching for a Webhost Provider
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question