Child pages
  • Jenkins got java.awt.headless problem
Skip to end of metadata
Go to start of metadata
Problem

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/fontconfig.properties 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

6 Comments

  1. 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. In addition to Stephaen's solution, I needed Sun JDK to make Jenkins work in my EC2 environment.

    FYI.

    https://groups.google.com/group/jenkinsci-users/browse_thread/thread/3d29da418b46f9a7?pli=1

  3. 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. h k

    Same problem on CentOS 5 with Jenkins 1.446, java-1.6.0-openjdk-1.6.0.0, 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. Also, make sure X can run in the first place:

    $ init 5

  6. yum install java-1.7.0-openjdk urw-fonts
    

    sufficed on CentOS 6.