fontconfig, Java, and Domino 11
Jan 29, 2021, 12:09 PM
In my last post, I quickly mentioned some trouble I had run into with fontconfig
and Poi, in the context of configuring a Docker-based Domino server. However, I think it deserves its own post, so I have something to point to if others run into the same trouble down the line.
The Upshot
The upshot of the issue is that, if you're going to use Poi or or other graphics-adjacent Java libraries in Domino 11 on Linux, you'll need fontconfig
and potentially some other support files installed on your system. If you have any GUI stuff installed, they'll probably be there, but it's common for them to be missing on headless servers.
For the official Domino Docker image, which uses Red Hat's package system, I wrote this Dockerfile for my derivative version:
FROM domino-docker:V1101FP2_10202020prod
USER root
RUN yum install --assumeyes fontconfig urw-fonts
USER notes
On Debian-based systems, I believe you just need apt install fontconfig
.
The Details
AdoptOpenJDK builds of Java apparently don't include the same font-related support files that the Oracle ones did, and that results in calls made to the AWT layer to throw NullPointerException
s at various times related to getting font information. This has shown up in a couple issues over in the openjdk-support
project on GitHub, with two representative ones being:
https://github.com/AdoptOpenJDK/openjdk-support/issues/80
java.lang.NullPointerException
at sun.awt.FcFontManager.getDefaultPlatformFont(FcFontManager.java:76)
at sun.font.SunFontManager$2.run(SunFontManager.java:433)
...
https://github.com/AdoptOpenJDK/openjdk-build/issues/693
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)
...
Domino 11 switched from IBM's proprietary variant of J9 to OpenJ9, and this is another one of the little fiddly details that isn't quite the same between the two.
Most commonly, I've found this crop up when using Poi, specifically calling autosizeColumns
when generating a spreadsheet, but in theory any number of things like that will trip across this. Unfortunately, the internal JVM classes aren't terribly helpful in their error reporting, since they get several method calls in just assuming that all is well with the world before bailing with the NPEs like above.
It's a mild annoyance to deal with, but fortunately one with a straightforward fix, at least once you know what the trouble is.