Child pages
  • Jenkins got java.awt.headless problem

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
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:

No Format
 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)

Code Block
sudo apt-get install ttf-dejavu

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

Code Block
sudo yum install dejavu-sans-fonts

On OpenSUSE:

Code Block
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

Code Block
sudo yum install fontconfig

On Alpine

Code Block
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)

Code Block
sudo apt-get install xvfb

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

Code Block
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":

Code Block
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.