UnsatisfiedLinkError: no fontmanager in system library path: /usr/lib/jvm/java-17-openjdk/lib
Asked Answered
A

1

6

After we migrated container to alpine_java-17 excel export feature fails with the next error:

java.lang.UnsatisfiedLinkError: no fontmanager in system library path: /usr/lib/jvm/java-17-openjdk/lib

In my Dockerfile I installed:

RUN apk add --no-cache fontconfig
RUN apk add --no-cache ttf-dejavu
RUN apk add --no-cache freetype

Here's short version of Dockerfile:

    FROM custom_registry/alpine_java-17


ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk


# procps to have the binary 'pgrep'
RUN apk update
RUN apk add curl
RUN apk add procps

#here's mu solution to fix the issue
RUN apk add --no-cache fontconfig
RUN apk add --no-cache ttf-dejavu
RUN apk add --no-cache freetype

# install bash
RUN apk add --no-cache bash

ENTRYPOINT [ "/app/bin/run.sh" ]

But it didn't help. Maybe someone knows how to fix the issue? Thanks in advance!

Aquitaine answered 13/5, 2022 at 8:42 Comment(10)
Please, could you provide a snippet of your Dockerfile? What library are you using for your Excel report generation?Engineering
you have to install jreTasteless
@biiyamn, jre is installed. My java application is running. Just one single functionality doesn't work.Aquitaine
@jccampanero, added a short version of Dockerfile. For excel report we're using Apache POI libAquitaine
Thank you very much for updating the question. I answered about the Dockerfile in order to trying understanding your installation. I honestly can tell, but you may have installed a headless version of the JDK; probably an obvious solution would be using the normal, non headless ,version of the JDK instead, and try again. Please, consider read this related SO question and github issue. I hope it helps.Engineering
Thanks a lot, @jccampanero. I'll try to check your solution and let you know once if help.Aquitaine
What version of Apache POI are you using ?Nonparticipating
@djmonki, we use 4.1.2 version of Apache POIAquitaine
OK - Wondering if it is an alpine issue. Please see this answer that I provided for another issue where the alpine os was the problem in regards to jdk11+: https://mcmap.net/q/1914754/-sonar-scanner-cli-4-2-does-not-find-jre-bin-javaNonparticipating
Yep. We're already changed the version from alpine to another one. Since we couldn't find any solution to resolve our case.Aquitaine
M
3

Several options:

Firstly, the standard Java install on Alpine is "headless" Java, which does not include any graphics libraries in the JRE lib directory. You need to ensure you have the non headless JRE installed. e.g. in your Dockerfile

RUN apk add --no-cache curl openjdk17-jre

If this still fails, you may need to debug the native libraries.

This looks like you have installed the correct packages, but their default location will not be the /usr/lib/jvm/java-17-openjdk/lib location that Java is looking in.

You can use apk to confirm the install location of the packages, my guess would be /usr/lib.

/ $ apk -L info fontconfig

Sample output (for lcms)

lcms2-2.12-r1 contains:
usr/lib/liblcms2.so.2
usr/lib/liblcms2.so.2.0.12

Then I think you have a couple of choices:

  1. Add symlinks from the /usr/lib/jvm/java-17-openjdk/lib directory to the actual library locations.

  2. Update your java startup property that specifies the system library location. e.g.

    -Djava.library.path="/usr/lib/jvm/java-17-openjdk/lib:/usr/lib"

Mikkanen answered 20/5, 2022 at 17:8 Comment(1)
Actually, I already tried these approaches and no one helped. I tried everything from this discussion: github.com/AdoptOpenJDK/openjdk-docker/issues/75 Right now we decided to move from alpine to another versionAquitaine

© 2022 - 2024 — McMap. All rights reserved.