0

I am trying to build a sap java connector using springboot. To build this app we need sapjco3.jar and sapjco3.so.

I am using Hibersap library and have added the maven jar dependencies. In the documentation it says to run the the app we need pass the java.library.path={path to the .so file} in java params.

The application is running fine in linux but I am facing :

Caused by: java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: /usr/lib/libsapjco3.so: libuuid.so.1: cannot open shared object file: No such file or directory

when I am trying to run in Docker.

I have added this in my dockerfile. :

VOLUME ["/var/log/hip"]
ADD maven/@file@ app.jar
COPY libsapjco3.so /usr/lib/libsapjco3.so
RUN chmod a+x -R /usr/lib/libsapjco3.so
RUN sh -c 'touch /app.jar'
CMD [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar --logging.path=/var/log/hip"]

and I am trying the path using:

System.setProperty("java.library.path","/usr/lib");

As I said, this is working in windows using dll and linux using but it is failing in docker running linux.

Elgarni
  • 236
  • 2
  • 5

2 Answers2

3

I had same problem (WSO2 Docker image and SAP integration), try to install "libuuid" package inside your Docker image. SAP connector was searching for libuuid, so I installed it and it started up. I was using Alpine Linux inside Docker image and this helped:

apk add libuuid
Dharman
  • 30,962
  • 25
  • 85
  • 135
0

My working solution with amazoncorretto docker image and Spring Boot application :

FROM amazoncorretto:11.0.18-al2023

ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar

COPY src/main/resources/lib/libsapjco3.so /opt/sap/libsapjco3.so
COPY src/main/resources/lib/sapjco3.jar /opt/sap/sapjco3.jar

ENV CLASSPATH="/opt/sap/sapjco3.jar:${CLASSPATH}"
ENV LD_LIBRARY_PATH="/opt/sap"

ENTRYPOINT ["sh", "-c", "java -cp app.jar -Dloader.path=/opt/sap/ org.springframework.boot.loader.PropertiesLauncher"]
Tomasz
  • 884
  • 8
  • 12