java.lang.NoClassDefFoundError: sun/awt/X11GraphicsEnvironment

This error was reported by QA during an attempt to display charts in Weblogic application created with JFreeChart

Root cause of ServletException.
java.lang.NoClassDefFoundError: sun/awt/X11GraphicsEnvironment
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1141)
at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1212)
at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1193)
at org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:174)
at org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:120)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3228)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2002)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1908)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1362)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)

It appears that I have to set java.awt.headless to true so that the JRockit JVM will implement AWT in software, rather than attempting to use non-existent hardware-based monitor on Linux box. The follow property was specified at the java command line JFreeChart are correctly displayed now.
-Djava.awt.headless=true

No comments: