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

Posted on 2007-10-09
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(
      at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(
      at sun.awt.X11.XToolkit.<clinit>(
 I'd appreciate your kind guidance in solving this problem    
Question by:Rrugemalira
    LVL 20

    Expert Comment

    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 ( 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

    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

    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 27

    Assisted Solution

    System.setProperty("java.awt.headless", "true");
    aslo see  

    Author Comment

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    EvenOdd challenge 10 70
    JKS to store upstart data 2 53
    Convert BufferedReader to File 1 49
    Web Site Hosting 10 57
    In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    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.

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now