Skip to main content

Solving XPlanner's $DISPLAY issues on a headless Linux (Debian) server

A month or so ago at work we started playing around with XPlanner, a project planning and tracking tool for eXtreme Programming (XP) teams. I downloaded it to my Ubuntu workstation, unzipped it and ran startup_xplanner.sh. Everything worked fine, all the graphs displayed, all the reports, etc.

We then decided that we would start to use it seriously and so it needed moving to a central server. This is when our problems started. We started to get errors such as:

java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
.

This was due to XPlanner now running on a headless server but it requires the Java AWT graphics libraries to draw the graphs. These in turn use the underlying system's X server, which requires some kind of X server running.

After some investigation I found Xvfb, an X server virtual framebuffer which will happily run on a headless server.

To install Xvfb, login as root and then apt-get the package:

apt-get install xvfb

We now need to create a couple of start/stop scripts so that both Xvfb and XPlanner are started when the system reboots.

Create a file in /etc/init.d called xvfb with the contents below:

#!/bin/bash

if [ -z "$1" ]; then
echo "`basename $0` {start|stop}"
exit
fi

case "$1" in
start)
/usr/bin/X11/Xvfb :0.0 &
;;

stop)
killall Xvfb
;;
esac

Create another file in /etc/init.d called xplanner with the contents below:

#!/bin/bash

DISPLAY=:0.0
export DISPLAY

JAVA_HOME=/usr/local/tools/j2sdk1.4.2_04
export JAVA_HOME

XPLANNER_HOME=/usr/local/tools/xplanner-0.7b4-standalone

if [ -z "$1" ]; then
echo "`basename $0` {start|stop}"
exit
fi

cd $XPLANNER_HOME

case "$1" in
start)
$XPLANNER_HOME/startup_xplanner.sh
;;

stop)
$XPLANNER_HOME/shutdown_xplanner.sh
;;
esac

cd -

We need to ensure that Xvfb is up and running before XPlanner attempts to start, so we need to force the order in which the start/stop scripts are executed:

update-rc.d xvfb defaults 10
update-rc.d xplanner defaults 80

Now reboot the server and you should have an auto-starting XPlanner which actually displays the graphs!

Technorati Tags: , , , , , ,

Comments

Anonymous said…
The other option is to set the java system property java.awt.headless=true

http://javatechniques.com/public/java/docs/hosting/headless-java-x11-libraries.html
Andrew Beacock said…
The XPlanner startup scripts include that statement but it still doesn't work without the virtual xserver. I think it's something to do with the generation of the graphs.
Anonymous said…
The headless system property enables generation of the charts on a headless server. This works on most servers. It's strange it didn't work on yours.
Anonymous said…
yo,

I experienced the same problem as abeacock. Thanks for the tip to a headless server. I'll check into the automation scripts soon.

Ps - I've emailed xplanner-devel@lists.sourceforge.net
to add this alternative option to the installation faq.

Pps - I've wanted to add a number of items to the FAQ, but it's not a wiki. I'm thinking of hosting a wiki to support Xplanner use, since I want to help others try out the software easier. What do ya'll think?
Andrew Beacock said…
diN0bot, that wiki sounds like a great idea, please post a link to it if you get one up and running, and I'll also do a proper post advertising it.