quarkus: OpenCV does not work in native mode (UnsatisfiedLinkError)
Describe the bug OpenCV does not work when the application is compiled to native.
Expected behavior The call completes correctly
Actual behavior While using OpenCV classes in native mode the application crashes with:
2021-02-17 14:33:29,348 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /hello failed, error id: 39d6a967-b519-443a-80ce-1f7550c9ca52-1: org.jboss.resteasy.spi.UnhandledException
: java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_zeros(III)J [symbol: Java_org_opencv_core_Mat_n_1zeros or Java_org_opencv_core_Mat_n_1zeros__III]
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:138)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:41)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:93)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_zeros(III)J [symbol: Java_org_opencv_core_Mat_n_1zeros or Java_org_opencv_core_Mat_n_1zeros__III]
at com.oracle.svm.jni.access.JNINativeLinkage.getOrFindEntryPoint(JNINativeLinkage.java:153)
at com.oracle.svm.jni.JNIGeneratedMethodSupport.nativeCallAddress(JNIGeneratedMethodSupport.java:57)
To Reproduce
https://github.com/ntrp/quarkus-jni-opencv-issue
Steps to reproduce the behavior:
- compile to native with
mvn package -Pnative -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:21.0-java11(tried also with standard 20.3) - run application
- call
curl localhost:8080/hello
Environment (please complete the following information):
- Output of
uname -aorver: Linux mimacom-ivor-xps13 5.10.14-arch1-1 #1 SMP PREEMPT Sun, 07 Feb 2021 22:42:17 +0000 x86_64 GNU/Linux - Output of
java -version: openjdk version “11.0.10” 2021-01-19 OpenJDK Runtime Environment (build 11.0.10+9) OpenJDK 64-Bit Server VM (build 11.0.10+9, mixed mode) - GraalVM version (if different from Java): can be seen in the package flag
- Quarkus version or git rev: 1.11.3.Final
- Build tool (ie. output of
mvnw --versionorgradlew --version): Apache Maven 3.6.3 (NON-CANONICAL_2019-11-27T20:26:29Z_root)
Additional context I tried without the JNIRegistrationFeature and without, no difference. I have seen already other similar bug reports but nothing really that matches this specific case and error
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (15 by maintainers)
@ntrp I pushed the extension to Maven Central. Have fun!
@ntrp you can try this extension: https://github.com/quarkiverse/quarkus-opencv
Build it locally for now and I’ll release on Maven Central once I got some feedback from you.