Unable to Print Jasper Report in Docker Container with Alpine-based OpenJDK Image

31 Views Asked by At

I am encountering an issue while attempting to print a Jasper report within a Docker container using an Alpine-based OpenJDK image. The application runs smoothly when using a non-Alpine base image, but encounters problems when using Alpine-based images.

I am using JasperFillManager.fillReport(String sourceFileName, Map<String, Object> params, Connection connection) method for report printing in java.

Here's my Dockerfile that works fine with a non-Alpine base image:

FROM openjdk:17-jdk-slim

MAINTAINER my-company.com

RUN apt-get update && apt-get install fontconfig libfreetype6 -y && apt-get update

COPY target/classes/static/fonts/*.ttf /usr/local/share/fonts/
RUN fc-cache -fv

COPY target/my-java-app-?.?*.jar .

ENTRYPOINT ["java", "-jar", "/my-java-app-2.0.0.jar"]

EXPOSE 8040

However, when I switch to an Alpine-based OpenJDK image with the following Dockerfile, the reports are not printed and no exceptions are thrown:

FROM bellsoft/liberica-openjdk-alpine:17

MAINTAINER my-company.com

RUN apk update && apk add fontconfig freetype

COPY target/classes/static/fonts/*.ttf /usr/local/share/fonts/
RUN fc-cache -fv

COPY target/my-java-app-?.?*.jar .

ENTRYPOINT ["java", "-jar", "/my-java-app-2.0.0.jar"]

EXPOSE 8040

The application is responsible for printing Jasper reports, and it works fine with a non-Alpine base image. However, when using the Alpine-based OpenJDK image, the reports are not printed, and no exceptions are thrown.

I think the issue is with freetype library which is not allowing me to print the report.

I've ensured that the necessary fonts are copied and cached properly. Is there anything specific I need to configure or install in the Alpine-based image to enable Jasper report printing? Are there any known compatibility issues or additional dependencies required for Jasper printing within Alpine-based images?

Any insights or suggestions would be greatly appreciated. Thank you!

0

There are 0 best solutions below