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

GraalVM Native Image failed to load the required native library #682

Closed
zipper01 opened this issue Mar 2, 2024 · 6 comments · Fixed by #741
Closed

GraalVM Native Image failed to load the required native library #682

zipper01 opened this issue Mar 2, 2024 · 6 comments · Fixed by #741
Milestone

Comments

@zipper01
Copy link

zipper01 commented Mar 2, 2024

The jar file works fine but the native image compiled by GraalVM (21.0.2+13.1) throws UnsatisfiedLinkError exception:

java.lang.UnsatisfiedLinkError: failed to load the required native library
        at io.netty.incubator.codec.quic.Quic.ensureAvailability(Quic.java:80)
        at io.netty.incubator.codec.quic.QuicheQuicSslContext.<init>(QuicheQuicSslContext.java:78)
        at io.netty.incubator.codec.quic.QuicSslContextBuilder.build(QuicSslContextBuilder.java:371)
        at common.net.QuicStreamChannelHandler.listen(QuicStreamChannelHandler.java:306)
        at common.net.ServerEndpoint.listen(ServerEndpoint.java:85)
        at myapp.AgencyMgr.login(AgencyMgr.java:279)
        at myapp.ui.UIMgr.lambda$new$2(UIMgr.java:26)
        at myapp.ui.Tui$1.run(Tui.java:93)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:833)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:211)
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: /tmp/libnetty_quiche_linux_x86_6413187606951079597579.so
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryAbsolute(NativeLibrarySupport.java:100)
        at java.base@21.0.2/java.lang.ClassLoader.loadLibrary(ClassLoader.java:114)
        at java.base@21.0.2/java.lang.Runtime.load0(Runtime.java:852)
        at java.base@21.0.2/java.lang.System.load(System.java:2025)
        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:36)
        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:396)
        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:218)
        at io.netty.incubator.codec.quic.Quiche.loadNativeLibrary(Quiche.java:77)
        at io.netty.incubator.codec.quic.Quiche.<clinit>(Quiche.java:57)
        at io.netty.incubator.codec.quic.Quic.<clinit>(Quic.java:45)
        ... 9 more
        Suppressed: java.lang.UnsatisfiedLinkError: Can't load library: /tmp/libnetty_quiche_linux_x86_6413187606951079597579.so
                at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryAbsolute(NativeLibrarySupport.java:100)
                at java.base@21.0.2/java.lang.ClassLoader.loadLibrary(ClassLoader.java:114)
                at java.base@21.0.2/java.lang.Runtime.load0(Runtime.java:852)
                at java.base@21.0.2/java.lang.System.load(System.java:2025)
                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:36)
                at java.base@21.0.2/java.lang.reflect.Method.invoke(Method.java:580)
                at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:430)
                at java.base@21.0.2/java.security.AccessController.executePrivileged(AccessController.java:129)
                at java.base@21.0.2/java.security.AccessController.doPrivileged(AccessController.java:319)
                at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:422)
                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:388)
                ... 13 more
        Suppressed: java.lang.UnsatisfiedLinkError: No netty_quiche_linux_x86_64 in java.library.path
                at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:136)
                at java.base@21.0.2/java.lang.ClassLoader.loadLibrary(ClassLoader.java:106)
                at java.base@21.0.2/java.lang.Runtime.loadLibrary0(Runtime.java:916)
                at java.base@21.0.2/java.lang.System.loadLibrary(System.java:2063)
                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:396)
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161)
                ... 12 more
                Suppressed: java.lang.UnsatisfiedLinkError: No netty_quiche_linux_x86_64 in java.library.path
                        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:136)
                        at java.base@21.0.2/java.lang.ClassLoader.loadLibrary(ClassLoader.java:106)
                        at java.base@21.0.2/java.lang.Runtime.loadLibrary0(Runtime.java:916)
                        at java.base@21.0.2/java.lang.System.loadLibrary(System.java:2063)
                        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                        at java.base@21.0.2/java.lang.reflect.Method.invoke(Method.java:580)
                        at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:430)
                        at java.base@21.0.2/java.security.AccessController.executePrivileged(AccessController.java:129)
                        at java.base@21.0.2/java.security.AccessController.doPrivileged(AccessController.java:319)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:422)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:388)
                        ... 13 more

Here is the code snippet in my QuicStreamChannelHandler.java:

    QuicSslContext sslCtx = QuicSslContextBuilder.forClient()
            .trustManager(cert)
            .applicationProtocols("http/1.1").build();
    ChannelHandler codec = new QuicClientCodecBuilder().sslContext(sslCtx)
            .maxIdleTimeout(2000, TimeUnit.MILLISECONDS)
            .initialMaxData(23450)
            .initialMaxStreamDataBidirectionalLocal(23450)
            .build();

In the jar file, META-INF/native-image/io.netty.incubator/netty-incubator-codec-native-quic/resource-config.json is there with the contents:

{
  "resources":{
  "includes":[
    {
      "condition":{"typeReachable":"io.netty.incubator.codec.quic.Quiche"},
      "pattern":"\\QMETA-INF/native/libnetty_quiche_osx_x86_64.jnilib\\E"
    },
    {
      "condition":{"typeReachable":"io.netty.incubator.codec.quic.Quiche"},
      "pattern":"\\QMETA-INF/native/libnetty_quiche_osx_aarch_64.jnilib\\E"
    },
    {
      "condition":{"typeReachable":"io.netty.incubator.codec.quic.Quiche"},
      "pattern":"\\QMETA-INF/native/libnetty_quiche_linux_x86_64.so\\E"
    },
    {
      "condition":{"typeReachable":"io.netty.incubator.codec.quic.Quiche"},
      "pattern":"\\QMETA-INF/native/libnetty_quiche_linux_aarch_64.so\\E"
    },
    {
      "condition":{"typeReachable":"io.netty.incubator.codec.quic.Quiche"},
      "pattern":"\\QMETA-INF/native/netty_quiche_windows_x86_64.dll\\E"
    }
  ]},
  "bundles":[]
}

and in META-INF/native/, file libnetty_quiche_linux_x86_64.so and netty_quiche_windows_x86_64.dll are there.
I noticed that in the exception it says can't load library /tmp/libnetty_quiche_linux_x86_6413187606951079597579.so, I didn't dig into Quic.ensureAvailability and don't understand where the value 13187606951079597579 (looks like a random number) came from, and how /tmp/libnetty_quiche_linux_x86_6413187606951079597579.so maps to META-INF/native/libnetty_quiche_linux_x86_64.so.

@zipper01
Copy link
Author

@normanmaurer - may you kindly look into this -- It's been pending for a while. Thanks.

@normanmaurer
Copy link
Member

Sorry but I really have no idea about graal

@violetagg
Copy link
Member

I may take a look in the next days ...

@zipper01
Copy link
Author

zipper01 commented Apr 6, 2024

Can anyone kindly help, it's been pending for a while...

@zipper01
Copy link
Author

zipper01 commented May 5, 2024

use netty-incubator-codec-native-quic 0.0.62.Final the problem still exists. 2 months cannot resolve.

@FoghostCn
Copy link
Contributor

I also encountered the same problem

normanmaurer pushed a commit that referenced this issue Aug 26, 2024
Motivation:

We should be able to use this library with GraalVM.

Modifications:

Fix meta-data.

Result:
Be able to use with native image. Fix #682
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

Successfully merging a pull request may close this issue.

4 participants