AdoptOpenJDK 8 NullPointerException sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)

I recently had to deal with this little bugger as we moved from the OpenJDK 8 package supplied by the Linux distro of choice to AdoptOpenJDK 8. It is important to know that we completely uninstalled OpenJDK, including all its transient dependencies.

(And in due time we’ll uninstall Java 8 and replace that grandpa as well)

As a result, parts of our application didn’t work any longer, resulting in this nice and shiny Java stacktrace.

2019-05-03 08:22:07,345 ERROR [qtp1896708863-35] [PlotChartController] [/][/][/]- error while creating chart image
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.defaultLineMetrics(Font.java:2176)
        at java.awt.Font.getLineMetrics(Font.java:2246)
        at org.jfree.chart.axis.DateAxis.estimateMaximumTickLabelWidth(DateAxis.java:1453)
        at org.jfree.chart.axis.DateAxis.selectHorizontalAutoTickUnit(DateAxis.java:1365)
        at org.jfree.chart.axis.DateAxis.selectAutoTickUnit(DateAxis.java:1340)
        at org.jfree.chart.axis.DateAxis.refreshTicksHorizontal(DateAxis.java:1616)
        at org.jfree.chart.axis.DateAxis.refreshTicks(DateAxis.java:1556)
        at org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:807)
        at org.jfree.chart.plot.CombinedDomainXYPlot.calculateAxisSpace(CombinedDomainXYPlot.java:364)
        at org.jfree.chart.plot.CombinedDomainXYPlot.draw(CombinedDomainXYPlot.java:442)
        at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1235)
        at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1409)
        at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1389)
        at org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:183)

I obviously removed some (a lot) parts to make it more readable and to hide corporate IP 😉 But this is the relevant part.

I found this bug report on Github and for once, plowing through the comments, it helped me. As is mentioned there, the culprit is the missing “fontconfig” package. So, I added another Ansible task to our playbook to provision the server et voila, the problem is gone.

- name: Install fontconfig package
  package:
    name: fontconfig
    state: present
    tags:
      - java

As mentioned earlier, we had wiped all that was relevant to OpenJDK off the system and by doing so, also uninstalled the “fontconfig” package. Otherwise this error wouldn’t have surfaced. But that’s the benefit of starting with a clean slate. This way you know if something is missing and don’t get surprised by errors all of a sudden while, at the same time, it is working on another machine.

Why a MacBook in Favor of Windows or Linux Laptops

As discussed in a recent blog post, I was in the market for a laptop. Several days after I had written about that topic and spent countless hours researching pros and cons, I had made the decision and went out to buy one. As the title suggests, it resulted in the most expensive product of the three options I was looking at and I’m here to write about it. This, however, is not the review as it would clearly blow up this piece. I’ll leave that for another day (I have written >1000 words already *tease*). In this blog post I’ll be explaining myself. Why I went with the MacBook Pro over the much more affordable and better equipped non-Mac laptops.

Read More »

New Laptop: Windows, macOS or Linux?

I am pondering the idea of buying a laptop and I’m having troubledeciding on the platform. Ultimately, sometime in the future, I’dlike to get rid of my stationary PC and replace it with

  1. a laptop as the center of my data and (hobby) work and
  2. a console for gaming.

The latter is a long term plan because I wouldalso need a better television. Right now, all my gaming is Windowsbased and therefore I’m still somewhat bound to that OS. But that’sa different topic.

I do not explicitly need a mobile computer.There’s nothing technically wrong with my PC. In fact, moving to alaptop would mean to sacrifice a lot of performance. But I really donot like to place myself in front of the desk to get something done.I don’t even play games as much any more. And that’s solelybecause it feels too much like work-work. Apart from it being apretty sleek looking PC tower instead of a notebook hooked up to twomonitors as is the case at work, the act of sitting in a chair infront of a big desk feels too much like being at work. Don’tget me wrong, I like my profession and I even like going to theoffice (again; after switching jobs). I’d even like to tinker athome some more. But, as I was saying, I don’t want it to feel likework. Sitting at the desk is also very constraining. I have to be inthis one particular spot to do some computing. In that regard I’meven more flexible at work because I could just pop out the computerfrom its docking station and go somewhere else. Why can’t I freelychoose where I want to sit with my computer when I’m at home? I amactively procrastinating as a result. I do have ideas for projects tocode and to write and it makes me sad that I do not want to pursuethem.

Read More »