Wednesday, October 01, 2008

java.awt.headless

We were using JFreeChart at that time, on our development machine everything ran smooth, chart appeared, no error. Until we deployed it on the production server (wait, am I not mentioning any staging server here? yep, no staging server mentioned.. just another recipe for disaster), the chart was gone, error message was the only clue we had. Google here, google there and we ended up with this great remedy that saved our asses.

The error message was :
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.

I've tried to set the DISPLAY variable in the environment to no avail, the other solution we found was to set java.awt.headless=true, indeed this was the option that we need to add before we run the server.
The key was on the production server there was no X-server running (we used rhel), everything done thru the console (which bring to my mind, what is wrong with having a nice GUI helping you, instead of all in text... i'm not against it, I'm just looking for improvement).
Setting headless to true, tells the jvm that it lacks either display device, keyboard or mouse. Luckily for us JFreeChart doesn't use any graphical components that requires a display device.

One more thing to consider if someone is going to build a component related to displaying things on screen.

No comments: