Den B
Den B

Reputation: 921

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

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!

Upvotes: 6

Views: 2968

Answers (1)

Hedley
Hedley

Reputation: 1092

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"

Upvotes: 3

Related Questions