Search code examples
javaquarkusgraalvmquarkus-native

Quarkus native, not able to use a shared library from maven dependency


I'm trying to put a Quarkus server up using Graalvm with a maven dependency that loads a shared library(*.so file). However, after the server starts I'm getting a java.lang.UnsatisfiedLinkError.

Steps to reproduce the issue

git clone https://github.com/ricardocunha/h3-native-test

mvn clean package -DskipTests && docker build -f src/main/docker/Dockerfile.native -t quarkus/h3-test . && docker run -i --rm -p 8080:8080 quarkus/h3-test

GraalVM and environment:

GraalVM GraalVM 21.3.0

  • JDK major version: 11
  • OS: Linux (to be precise Ubuntu 20.04)
  • Architecture: AMD64

More details

The current error

  • java.lang.UnsatisfiedLinkError: Can't load library: /tmp/libh3-java.so

however, a File.canRead returns true. So, I'm not understanding what is happening.

The compilation command is:

native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 -H:-ParseOnce -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED -H:ResourceConfigurationFiles=resource-config.json -H:+PrintClassInitialization --allow-incomplete-classpath -H:+JNI -Djava.library.path=/tmp -H:JNIConfigurationResources=jniconfig.json -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -J-Djava.awt.headless=true -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http -H:NativeLinkerOption=-no-pie -H:-UseServiceLoaderFeature -H:+StackTrace h3-native-test-1.0.0-SNAPSHOT-runner -jar h3-native-test-1.0.0-SNAPSHOT-runner.jar```

Solution

  • So, after try to run as non-native the error is clear:

    java.lang.UnsatisfiedLinkError: /usr/lib/libh3-java.so: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /usr/lib/libh3-java.so)
    

    Running as native there was no information about GLIBC_2.29 not found. This library is a very core library so I decided to move from docker image quarkus-micro-image:1.0(GLIBC 2.28) to openjdk:11 as a base image since it is 2.31. Ubi-9 is beta at this moment.