Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-59396

AWT initialized even with -Djava.awt.headless=true

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • core
    • None
    • Jenkins v2.176.1, RedHat 7, AdoptOpenJDK jdk8u222-b10

      I tried to use AdoptOpenJDK jdk8u222-b10 instead of Oracle JDK 8.

      I need to change my JDK, that's not my choice, and I couldn't launch Jenkins because of this issue :

      hudson.util.AWTProblem: java.lang.NullPointerException
       at hudson.WebAppMain.contextInitialized(WebAppMain.java:193)
       at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4776)
       at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5240)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
       at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:629)
       at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1838)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       at java.lang.Thread.run(Thread.java:748)
      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:774)
       at sun.font.SunFontManager$2.run(SunFontManager.java:431)
       at java.security.AccessController.doPrivileged(Native Method)
       at sun.font.SunFontManager.<init>(SunFontManager.java:376)
       at sun.awt.FcFontManager.<init>(FcFontManager.java:35)
       at sun.awt.X11FontManager.<init>(X11FontManager.java:57)
       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:423)
       at java.lang.Class.newInstance(Class.java:442)
       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.<clinit>(ChartUtil.java:260)
       at hudson.WebAppMain.contextInitialized(WebAppMain.java:192)
       ... 13 more

      When I rollback to use the Oracle JDK, everything is fine.

      The problem seems to be the static initialisation bloc inside hudson.util.ChartUtil :

          static {
              try {
                  new Font("SansSerif",Font.BOLD,18).toString();
              } catch (Throwable t) {
                  awtProblemCause = t;
                  awtProblem = true;
              }
          }
       

      With such code, AWT is referenced even with -Djava.awt.headless=true, because it is static.

            Unassigned Unassigned
            jbreda Julien Bréda
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: