fontconfig, Java, and Domino 11
Jan 29, 2021, 12:09 PM
- AbstractCompiledPage, Missing Plugins, and MANIFEST.MF in FP10 and V10
- Domino 11's Java Switch Fallout
- fontconfig, Java, and Domino 11
- Notes/Domino 12.0.2 Fallout
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 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.
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
NullPointerExceptions 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:
java.lang.NullPointerException at sun.awt.FcFontManager.getDefaultPlatformFont(FcFontManager.java:76) at sun.font.SunFontManager$2.run(SunFontManager.java:433) ...
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.
tommaso - May 3, 2021, 1:12 PM
Hi, I'm running Domino 11FP2 on CentOS 8 .
with the Poi sheet.autoSizeColumn function I experienced exactly the java.lang.NullPointerException at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
error even avter installing fontconfig urw-fonts
Than I tried (after this : https://github.com/adoptium/adoptium-support/issues/70) providing a fontconfig.properties and the error changed to
java.lang.NullPointerException at sun.awt.FcFontManager.getDefaultPlatformFont(FcFontManager.java:76)
Can you suggest something? thanks a lot tommaso
Jesse Gallagher - May 10, 2021, 12:54 PM
Hmm, that's odd - the fontconfig/urw-fonts route worked well for my Docker image, but I haven't run Domino on actual CentOS. Maybe there's something else to it, though it's still surprising.
Ayhan - May 23, 2022, 1:06 PM
11 years later - this helped us a lot - thanks champ