19

I’m trying to set up Jenkins on a RackSpace ArchLinux Cloud Server, but I’ve been unable to.

Whenever I try to access Jenkins site, I get this error:

AWT is not properly configured on this server. Perhaps you need to run your container with "-Djava.awt.headless=true"?

java.lang.NullPointerException
    at sun.awt.X11FontManager.getDefaultPlatformFont(X11FontManager.java:779)
    at sun.font.SunFontManager$2.run(SunFontManager.java:428)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.SunFontManager.<init>(SunFontManager.java:371)
    at sun.awt.X11FontManager.<init>(X11FontManager.java:32)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at java.lang.Class.newInstance0(Class.java:372)
    at java.lang.Class.newInstance(Class.java:325)
    at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:80)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:71)
    at java.awt.Font.getFont2D(Font.java:489)
    at java.awt.Font.getFamily(Font.java:1186)
    at java.awt.Font.getFamily_NoClientCode(Font.java:1160)
    at java.awt.Font.getFamily(Font.java:1152)
    at java.awt.Font.toString(Font.java:1649)
    at hudson.util.ChartUtil.<clinit>(ChartUtil.java:229)
    at hudson.WebAppMain.contextInitialized(WebAppMain.java:175)
    at winstone.WebAppConfiguration.<init>(WebAppConfiguration.java:897)
    at winstone.HostConfiguration.initWebApp(HostConfiguration.java:131)
    at winstone.HostConfiguration.<init>(HostConfiguration.java:73)
    at winstone.HostGroup.initHost(HostGroup.java:85)
    at winstone.HostGroup.<init>(HostGroup.java:45)
    at winstone.Launcher.<init>(Launcher.java:197)
    at winstone.Launcher.main(Launcher.java:398)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at Main._main(Main.java:268)
    at Main.main(Main.java:96)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.tanukisoftware.wrapper.WrapperJarApp.run(WrapperJarApp.java:394)
    at java.lang.Thread.run(Thread.java:722)

So, what do you think it might be?

I’ve already tried setting JAVA_OPTS environmental variable, to no avail. I also tried executing Java with -Djava.awt.headless=true, or even setting it in conf/wrapper.conf as wrapper.app.parameter.3=-headless.

Any idea how may I tackle this problem? I’m so new at this...

Thanks in advance!

Andrés Botero
  • 1,042
  • 2
  • 10
  • 26

11 Answers11

31

On my fedora 17 64Bit machine, I had OpenJDK 1.7 installed and I yum installed Jenkins which was having the same issue. Setting up -Djava.awt.headless=true did not help.

Finally solved the issue by installing dejavu-sans-fonts:

yum install dejavu-sans-fonts
Ahsanul
  • 411
  • 4
  • 3
  • 3
    This worked for me on CentOS with OpenJDK 1.7 but only after I also installed fontconfig. – Todd Jan 18 '13 at 00:03
  • 1
    OpenSUSE: `zypper install dejavu-fonts` – Jesse Glick May 21 '14 at 17:07
  • Seconding that a clean CentOS 7 with Adopt OpenJDK 11 needed fontconfig installed, which has dejavu-sans-fonts as a dependency. Just dejavu-sans-fonts by themselves didn't do it. – Hammer Bro. Jul 26 '21 at 20:46
24

Finally found a solution.

Believe it or not, it was actually just a matter of installing ttf-dejavu font!

I’m ashamed...

Andrés Botero
  • 1,042
  • 2
  • 10
  • 26
  • 1
    Don't be!! It can happen to anyone! The Headless error can be very tricky to understand the route cause! – sdmythos_gr Nov 17 '11 at 12:53
  • 1
    In my case (also Arch Linux here) having ttf-dejavu did not help when tried to run Jenkins with OpenJDK. Only after installing Oracle JDK Jenkins started without the specified error. – jmu Feb 05 '12 at 16:55
9

Installation of java-1.6.0-openjdk resulted in the following dependency's:

  • fontconfig
  • libXfont
  • libfontenc
  • ttmkfdir
  • xorg-x11-font-utils
  • xorg-x11-fonts-Type1

After the installation of those packages and a restart of jenkis, everything worked as designed.

Zab0815
  • 91
  • 1
  • 1
  • Oracle java7 also need this dependencies, its not just openjdk – higuita Sep 20 '12 at 17:20
  • @Zab0815, just curious, what distro that you tried on and how did you get such a list of dependency? I just tried on both CentOS 6.3 and Fedora 17, with both java-1.6.0-openjdk and java-1.7.0-openjdk. I used yum deplist together with some shell filters. I got quite different output, but yours works! Thanks! – user183394 Oct 15 '12 at 18:41
  • This actually worked. Thanks a lot! – Serban Cezar Nov 24 '21 at 18:54
6

Having an ArchLinux 64 bit headless server, I have successfully configured jenkins to work by following steps:

  1. Installed ttf-dejavu package
  2. Installed fontconfig packages
  3. added to /etc/conf.d/tomcat7:

    CATALINA_OPTS="-Djava.awt.headless=true"

Illarion Kovalchuk
  • 5,774
  • 8
  • 42
  • 54
2

For me installing the fonts didn't help at all. For me it actually missed the fontconfig package.

Details: https://noobient.com/2014/10/01/jenkins-service-unavailable/

bviktor
  • 1,356
  • 13
  • 14
1
pacman -S ttf-dejavu

fixed it for my Archlinux box

MauricioOtta
  • 301
  • 3
  • 5
1

I had the same problem.
I'm using MobaXterm as a terminal for my linux account, and for me the solution was in MobaXterm. I had to enable X11 under Settings --> Configurations.

Moosh
  • 63
  • 1
  • 6
0

On Linux Server release 6.2 (Santiago) , you just need to specify below command.

export CATALINA_OPTS="-DJENKINS_HOME=/opt/itmsetup/apache-tomcat-6.0.37/jenkins -Xmx750m -Djava.awt.headless=true"                           

this has solved my problem.

Pragnesh Chauhan
  • 8,363
  • 9
  • 42
  • 53
0

Installing openjdk-7-jre-headless and ttf-dejavu made the difference for me on Ubuntu 12.04 LTC (Precise). The fonts are referenced by the font setup of the Java installation and the OpenJDK 7 package depends on libfontconfig1 and will thus actually use the fonts.

I'm using Jenkins from http://pkg.jenkins-ci.org/debian/ and by default you will get openjdk-6-jre-headless since the jenkins package depends on default-jre-headless, which in turn pulls in openjdk-6-jre-headless.

You can swap the packages using

$ aptitude install openjdk-7-jre-headless
$ aptitude remove default-jre-headless openjdk-6-jre-headless
Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
0

See the wiki page on this topic. Also cf. PR 538.

Jesse Glick
  • 24,539
  • 10
  • 90
  • 112
-1

By adding CATALINA_OPTS="-Djava.awt.headless=true" in setclasspath.sh file of tomcat/bin directory solved the problem.

Santhan Salai
  • 3,888
  • 19
  • 29
manoj
  • 142
  • 8