I am building a Java application that I will be hosting in a docker container. Part of this application is to use this library:
https://github.com/wooio/htmltopdf-java
It takes a URL and converts it to a PDF document. However, when running the .jar
file through docker I get the error that it's missing native dependencies:
java.lang.UnsatisfiedLinkError: Unable to load library '/tmp/io.woo.htmltopdf/wkhtmltox/0.12.5/libwkhtmltox.so': Native library (tmp/io.woo.htmltopdf/wkhtmltox/0.12.5/libwkhtmltox.so) not found in resource path
This is documented in the last section of the link above, that it needs these libraries to run correctly:
I have modified my Dockerfile
to try to install these dependencies at the docker build:
FROM openjdk:8-jdk-alpine
RUN sh -c 'apk update && apk add libssl1.0 libx11 libxext libxrender libstdc++ freetype fontconfig'
COPY server/target/server-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
I am new to docker, but I found this snippet of code in an issue of the github repo. But I still cannot get it to work.
Can you spot the issue here why I cannot run the program?
I am still getting the error java.lang.UnsatisfiedLinkError: Unable to load library '/tmp/io.woo.htmltopdf/wkhtmltox/0.12.5/libwkhtmltox.so': Native library (tmp/io.woo.htmltopdf/wkhtmltox/0.12.5/libwkhtmltox.so) not found in resource path
But when SSHing into the Docker container and looking into the tmp
-folder the io.woo.htmltopdf
-library is listed. The path tmp/io.woo.htmltopdf/wkhtmltox/0.12.5/libwkhtmltox.so
also exists in the docker container.
Could it be something with the path settings? That the Java application is not using the correct path somehow?
The app.jar
that is being run is located in the root folder, where the tmp
folder is also located - so it should find it?
I managed to do a workaround to this problem by using the native wkhtmltopdf
library together with the wkhtmltopdf java wrapper.