Menu

Jenkins Service Unavailable

So you’re trying to install Jenkins on a headless Linux server with a minimum set of packages, and when you’re trying to reach the web interface, you get something like this:

HTTP ERROR: 503
Problem accessing /. Reason:
Service Unavailable
Powered by Jetty://

Additionally, when you check the logs, you see this:

SEVERE: Failed to initialize Jenkins
hudson.util.AWTProblem: java.lang.NullPointerException
    at hudson.WebAppMain.contextInitialized(WebAppMain.java:182)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:782)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:424)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:774)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.Server.doStart(Server.java:282)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at winstone.Launcher.(Launcher.java:154)
    at winstone.Launcher.main(Launcher.java:354)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at Main._main(Main.java:293)
    at Main.main(Main.java:98)
Caused by: java.lang.NullPointerException
    at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
    at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219)
    at sun.awt.FontConfiguration.init(FontConfiguration.java:107)
    at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:753)
    at sun.font.SunFontManager$2.run(SunFontManager.java:431)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.SunFontManager.(SunFontManager.java:376)
    at sun.awt.X11FontManager.(X11FontManager.java:32)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at java.lang.Class.newInstance(Class.java:433)
    at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
    at java.awt.Font.getFont2D(Font.java:491)
    at java.awt.Font.getFamily(Font.java:1220)
    at java.awt.Font.getFamily_NoClientCode(Font.java:1194)
    at java.awt.Font.getFamily(Font.java:1186)
    at java.awt.Font.toString(Font.java:1683)
    at hudson.util.ChartUtil.(ChartUtil.java:229)
    at hudson.WebAppMain.contextInitialized(WebAppMain.java:181)
    ... 19 more

Sep 30, 2014 8:33:52 PM org.eclipse.jetty.util.log.JavaUtilLog warn
WARNING: Failed startup of context w.{,file:/var/cache/jenkins/war/},/var/cache/jenkins/war
java.lang.NullPointerException
    at jenkins.util.groovy.GroovyHookScript.run(GroovyHookScript.java:63)
    at hudson.util.BootFailure.publish(BootFailure.java:43)
    at hudson.WebAppMain.contextInitialized(WebAppMain.java:244)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:782)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:424)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:774)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.Server.doStart(Server.java:282)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at winstone.Launcher.(Launcher.java:154)
    at winstone.Launcher.main(Launcher.java:354)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at Main._main(Main.java:293)
    at Main.main(Main.java:98)

So what’s the deal? You Google for these errors, and you’ll find suggestions like specifiying -Djava.awt.headless=true to the JVM [1][2]. The problem with this suggestion is that your Jenkins service script probably already has that added. The Fedora RPM sure does:

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

So it doesn’t help. Now you may find other suggestions, like installing the DejaVu fonts [1][2]. Well, guess what, after you install them, it still fails.

So, what did I do then? I had two server instances with different sets of packages, one of them could run Jenkins just fine, the other couldn’t. So I did a diff on their lists of installed packages and simply started to install the missing packages till I found the responsible one. As it turned out, the troublemaker was fontconfig.

yum install fontconfig

And that’s it, at this point Jenkins will run just fine. Why Java needs fontconfig to run Jenkins is beyond me, but that’s just the way it is.

Conclusion? Installing the most minimum amount of packages isn’t always rewarding.

Tags: , , , , , , , ,