Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using DCM4CHE3 (5.26.1) and eclipse-temurin docker image not working with opencv #1242

Open
naveenagarwal999 opened this issue Sep 7, 2022 · 1 comment

Comments

@naveenagarwal999
Copy link

We are trying to create a image from dicom file and in process its using native java lib opencv. When we are using in windows machine and junit test cases, it works fine. When deploying in linux and eclipse-temurin docker image, it fails and gives the below error:

Using the below versions:
dcm4che3 v (5.26.1)

docker base package
ARG OPENJDK_IMAGE_NAME=eclipse-temurin
ARG OPENJDK_IMAGE_TAG=17.0.3_7-jdk-alpine

//Copy native opencv_java.so file (docker file)
RUN mkdir /home/test/lib
COPY src/main/resources/external-libraries/linux-x86_64/*.so /home/test/lib/

Exception while converting dicom to jpeg:

com.test.imagecreator.process.JpegConverter - #process(...): thrown java.lang.UnsatisfiedLinkError(/home/test/lib/libopencv_java.so: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /home/test/lib/libopencv_java.so)) out of jdk.internal.loader.NativeLibraries#load[-2] in 420ms
09/06/22 14:41:02.591 ERROR [Camel (camel-1) thread #2 - JmsConsumer[dev.normal-UNZIPD]] com.test.imagecreator.route.ImageCreatorRoute - Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: , CaughtExceptionType: org.apache.camel.CamelExecutionException, CaughtExceptionMessage: Exception occurred during execution on the exchange: Exchange[35E1464D5DAD361-0000000000000001], StackTrace: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[35E1464D5DAD361-0000000000000001] at org.apache.camel.CamelExecutionException.wrapCamelExecutionException(CamelExecutionException.java:45) at org.apache.camel.support.AbstractExchange.setException(AbstractExchange.java:591) at org.apache.camel.support.DefaultExchange.setException(DefaultExchange.java:27) at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:288) at org.apache.camel.component.bean.AbstractBeanProcessor.process(AbstractBeanProcessor.java:146) at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:81) at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.doRun(RedeliveryErrorHandler.java:818) at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.run(RedeliveryErrorHandler.java:726) at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:193) at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64) at org.apache.camel.processor.Pipeline.process(Pipeline.java:185) at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398) at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:83) at org.apache.camel.support.AsyncProcessorSupport.process(AsyncProcessorSupport.java:41) at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:132) at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:736) at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:696) at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:674) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:331) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:270) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1237)

We then tried to load glibc since eclipse-temurin version is slimmed and don't have glibc.

//Used below in docker file...

ENV GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc
ENV GLIBC_VERSION=2.35-r0

RUN set -ex &&
apk --update add libstdc++ curl ca-certificates &&
for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION};
do curl -sSL ${GLIBC_REPO}/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done &&
apk add --allow-untrusted /tmp/.apk &&
rm -v /tmp/
.apk &&
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib

RUN rm /lib64/ld-linux-x86-64.so.2
RUN ln -s /usr/glibc-compat/lib/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2

Still it fails to covert and now we are getting the below error:

JmsConsumer[dev.normal-UNZIPD]] com.test.imagecreator.process.JpegConverter - #process(...): thrown java.lang.UnsatisfiedLinkError(/home/test/lib/libopencv_java.so: Error relocating /lib/ld-linux-x86-64.so.2: unsupported relocation type 37) out of jdk.internal.loader.NativeLibraries#load[-2] in 558ms
09/06/22 21:04:09.703 ERROR [Camel (camel-1) thread #2 - JmsConsumer[dev.normal-UNZIPD]] com.test.imagecreator.route.ImageCreatorRoute - Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: , CaughtExceptionType: org.apache.camel.CamelExecutionException, CaughtExceptionMessage: Exception occurred during execution on the exchange: Exchange[295600BEC1F18A1-0000000000000001], StackTrace: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[295600BEC1F18A1-0000000000000001] at org.apache.camel.CamelExecutionException.wrapCamelExecutionException(CamelExecutionException.java:45) at org.apache.camel.support.AbstractExchange.setException(AbstractExchange.java:591) at org.apache.camel.support.DefaultExchange.setException(DefaultExchange.java:27) at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:288) at org.apache.camel.component.bean.AbstractBeanProcessor.process(AbstractBeanProcessor.java:146) at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:81) at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.doRun(RedeliveryErrorHandler.java:818) at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.run(RedeliveryErrorHandler.java:726) at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:193) at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64) at org.apache.camel.processor.Pipeline.process(Pipeline.java:185) at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398)

Expected behavior
The image should be created from dicom file.

Additional context
Eclipse temurin (17.0.3_7-jdk-alpine) and OpenCV (*.so) file that we got from
https://maven.dcm4che.org/org/dcm4che/dcm4che-assembly/5.26.1/dcm4che-assembly-5.26.1-bin.zip (dcm4che-5.26.1\lib\linux-x86-64) file, is this compatible to run with docker version?

Thanks!!

@nroduit
Copy link
Member

nroduit commented Dec 30, 2022

The alpine distribution does not support glibc. See requirement https://github.com/dcm4che/dcm4che#dcm4che-dicom-toolkit--library.

So prefer an image like 17-jdk-jammy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants