adam bien's blog

Jenkins: hudson.util.AWTProblem: java.lang.NullPointerException And Solution 📎

The following Jenkins (1.548) exception is caused by the lack of the "devel" part of the JDK.


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)
[...]
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:430)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.font.SunFontManager.<init>(SunFontManager.java:375)
	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:408)
[...]

The problem can be mitigated by installing the full jdk. e.g.: yum -y install java-1.8.0-openjdk-devel or installing the current https://jdk8.java.net. However, the Jenkins 1.548 is using an older XStream library, which is not compatible with Java 8. If you get the following exception: http://jira.codehaus.org/browse/XSTR-746 you will have to move "back" to JDK 1.7.

See you at Java EE Workshops at MUC Airport or on demand and in a location very near you: airhacks.io!