Reputation: 1092
We are using Apache pdfbox. After switching from Java 8 on RedHat Linux, to Java 11 or Java 17 on Alpine linux, we get the following error:
java.lang.NoClassDefFoundError: Could not initialize class
org.apache.pdfbox.pdmodel.PDDocument at
com.openhtmltopdf.pdfboxout.PdfBoxRenderer.<init>(PdfBoxRenderer.java:118) at
com.openhtmltopdf.pdfboxout.PdfRendererBuilder.buildPdfRenderer(PdfRendererBuilder
com.openhtmltopdf.pdfboxout.PdfRendererBuilder.run(PdfRendererBuilder.java:35) at
The root error is:
UnsatisfiedLinkError: no lcms in system library path: /usr/lib/jvm/java-17-openjdk/lib
Upvotes: 0
Views: 718
Reputation: 1092
The root cause was that the default JRE for Alpine is a "headless" distribution that does not include graphics libraries such as the lcms library. To fix the issue we updated our docker build instructions to install the non headless version:
ENV JAVA_VERSION 17.0.3_p7-r2
# use full version of JRE!
RUN apk add --no-cache curl openjdk17-jre
If you want to see the differences between the openjdk17-jre and open-jdk17-headless, you can do so at:
https://pkgs.alpinelinux.org/packages
Note that the "non headless" package is additional. i.e. the base JRE package is installed first, then the non headless package simply adds the graphics libraries.
Upvotes: 3