question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnsatisfiedLinkError: how to shade native

See original GitHub issue

Expected behavior

Uses Channel from gRPC with Unix Domain Sockets

Actual behavior

Throwable is launched:

java.lang.UnsatisfiedLinkError: io.netty.shadednetty.channel.epoll.NativeStaticallyReferencedJniMethods.epollin()I
        at io.netty.shadednetty.channel.epoll.NativeStaticallyReferencedJniMethods.epollin(Native Method) ~[app-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
        at io.netty.shadednetty.channel.epoll.Native.<clinit>(Native.java:69) ~[app-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
        at io.netty.shadednetty.channel.epoll.IovArray.<clinit>(IovArray.java:57) ~[app-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
        at io.netty.shadednetty.channel.epoll.EpollEventLoop.<init>(EpollEventLoop.java:54) ~[app-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
...
java.lang.NoClassDefFoundError: Could not initialize class io.netty.shadednetty.channel.epoll.IovArray
        at io.netty.shadednetty.channel.epoll.EpollEventLoop.<init>(EpollEventLoop.java:54) ~[app-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
        at io.netty.shadednetty.channel.epoll.EpollEventLoopGroup.newChild(EpollEventLoopGroup.java:134) ~[app-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
        at io.netty.shadednetty.channel.epoll.EpollEventLoopGroup.newChild(EpollEventLoopGroup.java:35) ~[app-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
...

Steps to reproduce

Channel channel = NettyChannelBuilder.forAddress(new DomainSocketAddress("/tmp/somesoscket.socket"))
                .eventLoopGroup(new EpollEventLoopGroup())
                .channelType(EpollDomainSocketChannel.class)
                .usePlaintext(true)
                .build();

Netty version

4.1.8

gRPC version

1.2.0

JVM version (e.g. java -version)

java version “1.8.0_111” Java™ SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot™ 64-Bit Server VM (build 25.111-b14, mixed mode)

OS version (e.g. uname -a)

Linux MarcUbuntu16 4.4.0-72-generic #93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

My netty dependencies are (gradle project): compile 'io.netty:netty-all:4.1.8.Final' compile 'io.netty:netty-transport-native-epoll:4.1.8.Final:linux-x86_64'

I’m shading io.netty to io.netty.shadednetty using shadow plugin as I have other netty dependencies in the project. Most of the strings in /tmp/libnetty-transport-native-epollxxxxxxxxx.so looks like:

Java_io_netty_channel_unix_FileDescriptor_writeAddress
Java_io_netty_channel_epoll_Native_sizeofEpollEvent
Java_io_netty_channel_unix_Socket_getReceiveBufferSize
Java_io_netty_channel_epoll_Native_splice0
Java_io_netty_channel_unix_Errors_errnoEWOULDBLOCK
Java_io_netty_channel_epoll_Native_setTcpNotSentLowAt
Java_io_netty_channel_epoll_Native_epollin
Java_io_netty_channel_unix_Socket_isKeepAlive

where they should look like:

Java_io_netty_shadednetty_channel_unix_FileDescriptor_writeAddress
Java_io_netty_shadednetty_channel_epoll_Native_sizeofEpollEvent
Java_io_netty_shadednetty_channel_unix_Socket_getReceiveBufferSize
Java_io_netty_shadednetty_channel_epoll_Native_splice0
Java_io_netty_shadednetty_channel_unix_Errors_errnoEWOULDBLOCK
Java_io_netty_shadednetty_channel_epoll_Native_setTcpNotSentLowAt
Java_io_netty_shadednetty_channel_epoll_Native_epollin
Java_io_netty_shadednetty_channel_unix_Socket_isKeepAlive

Any help about shading this would be great!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Scottmitchcommented, Apr 25, 2017

Sorry for the delay … but sounds like you got it. You need to set the system property and relocate the native library to match (to be sure we load the “correct” native library instead of potentially some other library).

1reaction
MarcMagnincommented, Apr 24, 2017

all good, With relocate 'io.netty', 'shade.io.netty', it needed a System.setProperty("shade.io.netty.packagePrefix", "shade."); and a rename of META-INF/native/lib-netty-transport-native-epoll.so to META-INF/native/libshade-netty-transport-native-epoll.so

Read more comments on GitHub >

github_iconTop Results From Across the Web

JNI -- UnsatisfiedLinkError on native method - Stack Overflow
Here is my actual code. NativeTest.java class NativeTest { public static native boolean nativemethod (String arg) ...
Read more >
How to Handle the UnsatisfiedLinkError Runtime Error in Java
The Java java.lang.UnsatisfiedLinkError is thrown when a program uses a native libaray but is unable to find it at runtime for some reason....
Read more >
NativeLibraryLoader xref - Netty
endsWith(expected)) { 108 throw new UnsatisfiedLinkError(String.format( 109 "Could not find prefix added to %s to get %s. When shading, only adding a "...
Read more >
Caused by: java.lang.UnsatisfiedLinkError: Could not find jnind4jcpu ...
I am getting this error on Linux operating systems. Windows works without any problems. Caused by: java.lang.UnsatisfiedLinkError: no jnind4jcpu in ...
Read more >
no netty_transport_native_epoll_x86_64 in java.library.path
UnsatisfiedLinkError : no netty_transport_native_epoll_x86_64 in ... loadNativeLibrary(Native.java:186) at io.netty.channel.epoll.Native.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found