Child pages
  • Jenkins got java.awt.headless problem

Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

Jenkins got java.awt.headless problem

I installed Jenkins in Ubuntu linux and run Jenkins in the tomcat6.

I open any Jenkins page which is showing a trend chart. I get the following error on the page:

Graphics N/A Unable to access X. You need to run the web container in the headless mode. Add -Djava.awt.headless=true to VM.

I check the tomcat6 starting script, the JVM property java.awt.headless is set to true already.
I check through the Jenkins' Manage Jenkins->System Information page. It also shows the java.awt.headless is set to true.

Looking through the Tomcat logs, the following error can be found:

 java.lang.Error: Probable fatal error:No fonts found.
Solution (for Open JDK)

We had the same problem too using Jenkins in Tomcat6 on Ubuntu 9.10 server.

Obviously graphics rendering needs access to font metrics. So check java /etc/java-6-openjdk/ and install missing fonts. OpenJDK refers to DejaVu-Fonts. So type:

On Ubuntu (or likely any Debian based Operating System)

sudo apt-get install ttf-dejavu

On CentOS 6 (or likely any RHEL based Operating System)

sudo yum install dejavu-sans-fonts

On OpenSUSE:

zypper install dejavu-fonts

In addition if you are using the OpenJDK Headless package (at least on CentOS 7) you will need to install fontconfig

sudo yum install fontconfig

On Alpine

sudo apk add ttf-dejavu

Restart Tomcat and enjoy graphics.

If this doesn't work, you may also need some of type rendering libraries that are usually part of an X server – in a truly headless system, xvfb will do.

On Ubuntu (or likely any Debian based Operating System)

sudo apt-get install xvfb

On CentOS 6 (or likely any RHEL based Operating System)

sudo yum install xorg-x11-server-Xvfb
Solution (for Sun JDK)

I also had the same problem using Jenkins in Tomcat 6 on Ubuntu 9.10 Server, but this time with Sun's JDK6.

I initially only installed the package 'sun-java6-jdk'. After seeing the above fonts error, I tried installing the 'sun-java6-fonts' package, but that didn't seem to solve my problem. I gave up trying to find the exact package I needed to get things working and just decided to remove what I had and reinstall the "whole shebang":

sudo apt-get remove sun-java6*
sudo apt-get install sun-java6*

Maybe a little brute'ish, but it worked. Jenkins now makes all of its pretty charts.

  • No labels


  1. Unknown User (steveanthony)

    I had to use yum to get the dejavu fonts and then symlink:

    # cd /usr/share/font

    # ln -s dejavu dejavu-lgc

    Note, this was on an Amazon EC2 instance (their linux distro), running OpenJDK.

  2. Unknown User (remore)

    In addition to Stephaen's solution, I needed Sun JDK to make Jenkins work in my EC2 environment.


  3. Unknown User (nickg)

    I needed the Sun JDK also, for Fedora 15 (thanks Kei).

    When the fonts become available, you should notice that the "Unable to access X..." message's fonts became "prettier".

    N.B. You'll have to kick off another build before the "Unable to access X..." image will be replaced with a trend graph.

  4. Unknown User (annoyed)

    Same problem on CentOS 5 with Jenkins 1.446, java-1.6.0-openjdk-, Linux version 2.6.18-128.el5PAE. Did what Stephen said:

    yum install dejavu-lgc-fonts
    cd /usr/share/fonts/
    ln -s dejavu-lgc dejavu

    Then kicked off another build as Nick suggested. If it still doesn't work for you, try restarting everything beginning with Jenkins.

  5. Unknown User (mlbright)

    Also, make sure X can run in the first place:

    $ init 5

  6. Unknown User (jglick)

    yum install java-1.7.0-openjdk urw-fonts

    sufficed on CentOS 6.