12

During starting Ktor application, I've got the following logs:

java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll_x86_64 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
    at java.lang.Runtime.loadLibrary0(Runtime.java:872)
    at java.lang.System.loadLibrary(System.java:1124)
    at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:369)
    at java.security.AccessController.doPrivileged(Native Method)
    at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:361)
    at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:339)
    at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
    at io.netty.channel.epoll.Native.loadNativeLibrary(Native.java:231)
    at io.netty.channel.epoll.Native.<clinit>(Native.java:58)
    at io.netty.channel.epoll.Epoll.<clinit>(Epoll.java:39)
    at io.ktor.server.netty.EventLoopGroupProxy$Companion.create(NettyApplicationEngine.kt:189)
    at io.ktor.server.netty.NettyApplicationEngine.<init>(NettyApplicationEngine.kt:74)
    at io.ktor.server.netty.EngineMain.main(EngineMain.kt:22)
22:56:07.760 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - netty_transport_native_epoll_x86_64 cannot be loaded from java.library.path, now trying export to -Dio.netty.native.workdir: /tmp
java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll_x86_64 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
    at java.lang.Runtime.loadLibrary0(Runtime.java:872)
    at java.lang.System.loadLibrary(System.java:1124)
    at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
    at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:349)
    at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
    at io.netty.channel.epoll.Native.loadNativeLibrary(Native.java:231)
    at io.netty.channel.epoll.Native.<clinit>(Native.java:58)
    at io.netty.channel.epoll.Epoll.<clinit>(Epoll.java:39)
    at io.ktor.server.netty.EventLoopGroupProxy$Companion.create(NettyApplicationEngine.kt:189)
    at io.ktor.server.netty.NettyApplicationEngine.<init>(NettyApplicationEngine.kt:74)
    at io.ktor.server.netty.EngineMain.main(EngineMain.kt:22)
    Suppressed: java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll_x86_64 in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
        at java.lang.Runtime.loadLibrary0(Runtime.java:872)
        at java.lang.System.loadLibrary(System.java:1124)
        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:369)
        at java.security.AccessController.doPrivileged(Native Method)
        at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:361)
        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:339)
        ... 7 common frames omitted
22:56:07.761 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - Unable to load the library 'netty_transport_native_epoll', trying other loading mechanism.
java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
    at java.lang.Runtime.loadLibrary0(Runtime.java:872)
    at java.lang.System.loadLibrary(System.java:1124)
    at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:369)
    at java.security.AccessController.doPrivileged(Native Method)
    at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:361)
    at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:339)
    at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
    at io.netty.channel.epoll.Native.loadNativeLibrary(Native.java:234)
    at io.netty.channel.epoll.Native.<clinit>(Native.java:58)
    at io.netty.channel.epoll.Epoll.<clinit>(Epoll.java:39)
    at io.ktor.server.netty.EventLoopGroupProxy$Companion.create(NettyApplicationEngine.kt:189)
    at io.ktor.server.netty.NettyApplicationEngine.<init>(NettyApplicationEngine.kt:74)
    at io.ktor.server.netty.EngineMain.main(EngineMain.kt:22)
22:56:07.761 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - netty_transport_native_epoll cannot be loaded from java.library.path, now trying export to -Dio.netty.native.workdir: /tmp
java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
    at java.lang.Runtime.loadLibrary0(Runtime.java:872)
    at java.lang.System.loadLibrary(System.java:1124)
    at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
    at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:349)
    at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
    at io.netty.channel.epoll.Native.loadNativeLibrary(Native.java:234)
    at io.netty.channel.epoll.Native.<clinit>(Native.java:58)
    at io.netty.channel.epoll.Epoll.<clinit>(Epoll.java:39)
    at io.ktor.server.netty.EventLoopGroupProxy$Companion.create(NettyApplicationEngine.kt:189)
    at io.ktor.server.netty.NettyApplicationEngine.<init>(NettyApplicationEngine.kt:74)
    at io.ktor.server.netty.EngineMain.main(EngineMain.kt:22)
    Suppressed: java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
        at java.lang.Runtime.loadLibrary0(Runtime.java:872)
        at java.lang.System.loadLibrary(System.java:1124)
        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:369)
        at java.security.AccessController.doPrivileged(Native Method)
        at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:361)
        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:339)
        ... 7 common frames omitted

the build file

plugins {
    application
    kotlin("jvm") version "1.3.61"
}

group = "io.oceanstack"
version = "1.0-SNAPSHOT"

val ktor_version = "1.3.1"

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    implementation(kotlin("stdlib-jdk8"))
    compile("io.ktor:ktor-server-core:$ktor_version")
    compile("io.ktor:ktor-server-netty:$ktor_version")
    compile("ch.qos.logback:logback-classic:1.2.3")
    testCompile(group = "junit", name = "junit", version = "4.12")
}

tasks {
    compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
    compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
}

application {
    mainClassName = "io.ktor.server.netty.EngineMain"
} 

What am I doing wrong?

The Java runtime:

 java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (Zulu 8.44.0.11-CA-linux64) (build 1.8.0_242-b20)
OpenJDK 64-Bit Server VM (Zulu 8.44.0.11-CA-linux64) (build 25.242-b20, mixed mode)
softshipper
  • 32,463
  • 51
  • 192
  • 400
  • You seem to be missing [`netty-tcnative`](https://netty.io/wiki/forked-tomcat-native.html). I assume you are on a 64-bit Linux with a 64-bit JRE, is that correct? – Elliott Frisch Feb 23 '20 at 22:06
  • Yes, exactly. I just post my Java runtime. What do I have to do? – softshipper Feb 23 '20 at 22:12
  • Install netty-tcnative. The directions for doing so vary, but search Google for "Install netty-tcnative " – Elliott Frisch Feb 23 '20 at 22:17
  • I tried with `sudo apt-get install -y libnetty-tcnative-java` on my Ubuntu 18.04, the error message still appears. – softshipper Feb 23 '20 at 22:24
  • You're not missing an OS dependency, you're missing a Java dependency. In order to use the netty epoll event group you need the epoll native jar: ```// https://mvnrepository.com/artifact/io.netty/netty-transport-native-epoll compile group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.46.Final'``` See https://netty.io/wiki/native-transports.html#using-the-linux-native-transport – petercable Mar 02 '20 at 02:15

1 Answers1

16

Switching from debug level to info or warn will hide this information.

If in the log further down there is

DEBUG io.netty.util.internal.NativeLibraryLoader - Successfully loaded the library /tmp/libnetty_transport_native_epoll_x86_646903432541420558.so

you're safe and should ignore the message (further up)

DEBUG io.netty.util.internal.NativeLibraryLoader - netty_transport_native_epoll_x86_64 cannot be loaded from java.library.path

It appears as a kind of try and error approach until an valid option is found, and it is tagged as an DEBUG message, so less relevant for library users which could go to INFO or WARNING log level or try suppressing this specific message.

See also here and here

Hartmut Pfarr
  • 5,534
  • 5
  • 36
  • 42
  • 1
    I really wish someone would answer with how to avoid the error, instead of just saying "this error is ok" as this is the second time I've seen this kind of response. There has to be some documentation out there which says how to add the shared object to the java.library.path instead of just saying "don't worry, it's not really an error because it retries after fixing itself" – Edwin Buck Apr 24 '22 at 08:19