UnsatisfiedLinkError: how to shade native
See original GitHub issueExpected 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:
- Created 6 years ago
- Comments:7 (4 by maintainers)
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).
all good, With
relocate 'io.netty', 'shade.io.netty'
, it needed aSystem.setProperty("shade.io.netty.packagePrefix", "shade.");
and a rename ofMETA-INF/native/lib-netty-transport-native-epoll.so
toMETA-INF/native/libshade-netty-transport-native-epoll.so