No xxx in java.library.path when using nested jar

Hi ,

I have a jar file whose name is sapdemo.jar , and there is a nested jar whose name is sapjco3.jar inside sapdemo.jar. it is located at \BOOT-INF\lib\sapjco3.jar inside the sapdemo.jar.

When running in the common OS with cmd : java -jar sapdemo.jar , it works well.

but when running it inside a docker container , it throw error :

[2021-04-16 17:27:58.627] http-nio-8088-exec-1 |-ERROR in DirectJDKLog.java:175 - Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Handler >dispatch failed; nested exception is java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path] with root cause
java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path

It seems that it can not find the sapjco3 in java.library.path .

This is the dockfile for the docker image:

FROM maven:3-jdk-8
COPY sapdemo-0.0.1-SNAPSHOT.jar /opt/
EXPOSE 8088
CMD java -jar /opt/sapdemo-0.0.1-SNAPSHOT.jar

It is still the same error even though I change the CMD to
“CMD java -Djava.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib -jar /opt/sapdemo-0.0.1-SNAPSHOT.jar”

There is a similar problem at “java - Error while loading .so library inside docker container when running a jar file - Stack Overflow” , but there is no solution for it .

Thank you

In fact , it is not related to docker container .
It is related to the OS env where the jar runs .

The sapjco3.jar needs a dll or so file to run .
For linux , you have to place libsapjco3.so to “$JAVA_HOME/jre/lib/amd64/”