OpenPOWER Library

 1.5.5. Java AWT exception

Use of Maven in headless environments from Mac OS has uncovered an intermittent exception in the AWT libraries. This error looks like the following:

...
---------------------------------------------------
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using 'localhost:11.0' as the value of the DISPLAY variable.
	at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
	at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
	at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103)
	at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82)
	at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:126)
...

The circumvention for this error, is force AWT to run headless. This can be accomplished by adding the -Djava.awt.headless=true parameter to the maven invocation such that it looks like this:

$ mvn clean generate-sources -Djava.awt.headless=true

loading table of contents...