wooio / htmltopdf-java

An HTML to PDF conversion library written in Java, based on wkhtmltopdf.
MIT License
173 stars 97 forks source link

Not working in docker #7

Closed lgabeskiria closed 6 years ago

lgabeskiria commented 6 years ago
java.lang.UnsatisfiedLinkError: Unable to load library '/tmp/io.woo.htmltopdf/wkhtmltox/0.12.4/libwkhtmltox.so': Native library (tmp/io.woo.htmltopdf/wkhtmltox/0.12.4/libwkhtmltox.so) not found in resource path
benbarkay commented 6 years ago

It seems to work for me in a simple test with a stock library/java docker container. It appears that for some reason in your case there's a failure to copy wkhtmltopdf library resources. Are you using version 1.0.2?

lgabeskiria commented 6 years ago

We have the following Dockerfile:

FROM frolvlad/alpine-oraclejdk8:slim

VOLUME /tmp
ADD project-1.0-SNAPSHOT.jar app.jar
RUN sh -c 'touch /app.jar'
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]

We are building docker image in Jenkins, then saving image in AWS

benbarkay commented 6 years ago

@lgabeskiria it looks like the library is being copied to /tmp and JNA is attempting to load it, the (rather misleading) error comes from that some dependencies are missing in the alpine image:

Error loading shared library libXrender.so.1: No such file or directory (needed by /tmp/io.woo.htmltopdf/wkhtmltox/0.12.4/libwkhtmltox.so)
Error loading shared library libfontconfig.so.1: No such file or directory (needed by /tmp/io.woo.htmltopdf/wkhtmltox/0.12.4/libwkhtmltox.so)
Error loading shared library libfreetype.so.6: No such file or directory (needed by /tmp/io.woo.htmltopdf/wkhtmltox/0.12.4/libwkhtmltox.so)
Error loading shared library libXext.so.6: No such file or directory (needed by /tmp/io.woo.htmltopdf/wkhtmltox/0.12.4/libwkhtmltox.so)
Error loading shared library libX11.so.6: No such file or directory (needed by /tmp/io.woo.htmltopdf/wkhtmltox/0.12.4/libwkhtmltox.so)
Error loading shared library libstdc++.so.6: No such file or directory (needed by /tmp/io.woo.htmltopdf/wkhtmltox/0.12.4/libwkhtmltox.so)

If you could find a way to install these libraries into your docker image, htmltopdf should work fine.

You can generate this output by running ldd libwkhtmltox.so in your container (where libwkhtmltox.so is the library file from the project)

benbarkay commented 6 years ago

If you add the following to your docker build script that should solve it:

RUN sh -c 'apk update && apk add libx11 libxext libxrender libstdc++ freetype fontconfig libssl1.0'
miguelbaldi commented 6 years ago

@benbarkay libc6-compat is missing too. I was able to get working with: RUN sh -c 'apk --update add libc6-compat libx11 libxext libxrender libstdc++ freetype fontconfig libssl1.0'

lgabeskiria commented 6 years ago

@benbarkay Thanks that worked for us (except fonts). But there is some strange behaviour: When calling API for first time it generates pdf, but second time it just goes to timeout.

I think the converter should be singleton.

benbarkay commented 6 years ago

@miguelbaldi his docker image has glibc2 installed on it so he did not need it. But that's good to know. @lgabeskiria could you open another issue with a snippet that would reproduce the behavior?

In any case, this has been helpful. I'll add this troubleshooting to the README.

lgabeskiria commented 6 years ago

@benbarkay https://github.com/wooio/htmltopdf-java/issues/8

jernejcvek commented 5 years ago

In my case (Ubuntu 18.04), the package libpng12-0 was missing:

Exact reason for this issue is that libpng12is no longer available in the Ubuntu repository archives. In-fact, Ubuntu dropped it from Ubuntu 16.10 too.

Possible solution is to install this package manually: wget http://security.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1.1_amd64.deb && sudo dpkg -i libpng12-0_1.2.54-1ubuntu1.1_amd64.deb && sudo rm -f libpng12-0_1.2.54-1ubuntu1.1_amd64.deb

lu598110900 commented 4 years ago

java.util.concurrent.ExecutionException: 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 ([file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/classes/, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/ant-1.9.7.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/ant-launcher-1.9.7.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/classmate-1.3.4.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/commons-beanutils-1.9.3.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/commons-codec-1.10.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/commons-collections-3.2.2.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/commons-lang3-3.9.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/curator-client-2.12.0.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/curator-framework-2.12.0.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/dubbo-2.6.2.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/dubbo-spring-boot-actuator-0.1.1.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/dubbo-spring-boot-autoconfigure-0.1.1.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/dubbo-spring-boot-starter-0.1.1.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/fastjson-1.2.60.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/flying-saucer-core-9.0.3.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/flying-saucer-pdf-itext5-9.0.3.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/greenline-guser-auth-share-1.0.0.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/groovy-2.4.15.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/guahao-specification-data-1.0.3.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/guahao-specification-service-1.0.2-SNAPSHOT.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/guahao-user-model-share-3.4.48.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/guahao-user-service-share-3.4.52.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/guava-19.0.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/hessian-4.0.38.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/hibernate-validator-5.3.6.Final.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/htmltopdf-1.0.8.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/httpclient-4.5.4.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/httpcore-4.4.9.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/httpmime-4.5.2.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/itext-asian-5.2.0.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/itextpdf-5.5.13.1.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/jackson-annotations-2.8.0.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/jackson-core-2.8.11.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/jackson-databind-2.8.11.1.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/javassist-3.21.0-GA.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/javax.el-2.2.6.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/javax.el-api-2.2.5.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/jboss-logging-3.3.2.Final.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/jcl-over-slf4j-1.7.25.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/jline-0.9.94.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/jna-4.2.2.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/jsqlparser-1.0.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/jul-to-slf4j-1.7.25.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/log4j-over-slf4j-1.7.25.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/logback-classic-1.1.11.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/logback-core-1.1.11.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/lombok-1.16.20.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/mybatis-3.4.6.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/mybatis-spring-1.3.2.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/mybatis-spring-boot-autoconfigure-1.3.2.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/mybatis-spring-boot-starter-1.3.2.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/mysql-connector-java-5.1.46.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/nekohtml-1.9.22.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/netty-3.10.6.Final.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/ognl-3.0.8.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/owasp-java-html-sanitizer-20190610.2-GH-SNAPSHOT.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/pagehelper-5.1.2.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/pagehelper-spring-boot-autoconfigure-1.2.3.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/pagehelper-spring-boot-starter-1.2.3.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/slf4j-api-1.7.25.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/snakeyaml-1.17.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-aop-4.3.17.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-beans-4.3.17.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-boot-1.5.13.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-boot-autoconfigure-1.5.13.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-boot-starter-1.5.13.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-boot-starter-jdbc-1.5.13.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-boot-starter-logging-1.5.13.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-boot-starter-thymeleaf-1.5.13.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-boot-starter-web-1.5.13.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-context-4.3.17.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-core-4.3.17.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-expression-4.3.17.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-jdbc-4.3.17.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-tx-4.3.17.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-web-4.3.17.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/spring-webmvc-4.3.17.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/thymeleaf-2.1.6.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/thymeleaf-layout-dialect-1.4.0.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/thymeleaf-spring4-2.1.6.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/tomcat-jdbc-8.5.31.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/unbescape-1.1.0.RELEASE.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/util-core-1.0.9.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/validation-api-1.1.0.Final.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/xercesImpl-2.11.0.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/xml-apis-1.4.01.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/xmlworker-5.5.9.jar, file:/tmp/jetty-0_0_0_0-7040-diagnosticwar--any-3574633427262141141.dir/webapp/WEB-INF/lib/zookeeper-3.4.9.jar])==========={hospitalId=1, numcard=1, studyIdApply=8596564634}

lu598110900 commented 4 years ago

在Linux 物理机上部署 不会成功

yasarutkuu commented 1 year ago

same problem, any solutions?

gilbertocosme commented 1 year ago

same problem, any solutions?

me too, so sad

lchonline commented 1 year ago

I got the same error.