On upgrading a piece of (1.4-dependent) server-side software from 1.4.2_01 to 1.4.2_14, I began seeing errors that looked like:
java.awt.HeadlessException at sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice (HeadlessGraphicsEnvironment.java:66) at javax.swing.RepaintManager.getVolatileOffscreenBuffer (RepaintManager.java:537) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4727) at javax.swing.JComponent.paint(JComponent.java:798) at edu.vt.cs.collab.cork.impl.servlet.CORKServlet.encodeComponentAsJPEG (CORKServlet.java:617) at org.isenhour.fin.inc.CEFChartWebView.writeChartImage(CEFChartWebView.java:97) at org.isenhour.fin.inc.CEFChartWebView.writeStaticContent(CEFChartWebView.java:84) at edu.vt.cs.collab.bridge.DefaultWebViewServlet.doGet(DefaultWebViewServlet.java:95) at edu.vt.cs.collab.cork.impl.servlet.CORKServlet.doGet(CORKServlet.java:293) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) ....
The offending code segment was:
img = new BufferedImage(sz.width, sz.height, BufferedImage.TYPE_INT_RGB); g = img.createGraphics(); g.setColor(Color.white); g.fillRect(0, 0, sz.width, sz.height); comp.setBounds(0, 0, sz.width, sz.height); comp.paint(g);
where comp
was a fairly uncomplicated Swing component. This turned out to be Sun bug 6189824. The work-around noted in the bug report, adding a call to:
javax.swing.RepaintManager.currentManager(null).setDoubleBufferingEnabled(false);
seems to have fixed the problem.