Failed to load any of the given libraries: [netty-tcnative-linux-x86_64,netty-tcnative]

孤者浪人 提交于 2019-12-24 00:59:45

问题


I have deployed a web-application inside a tomcat container and have used grpc-netty (1.2.0) with netty-tcnative-boringssl-static:jar:1.1.33.Fork26.

When i switch on debug logs it tells that "java.lang.IllegalArgumentException: Failed to load any of the given libraries: [netty-tcnative-linux-x86_64, netty-tcnative-linux-x86_64-fedora, netty-tcnative]" and then a error message "java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured.".

I have gone through the troubleshooting section of https://github.com/grpc/grpc-java/blob/master/SECURITY.md and have verified my netty versions and this looks to be fine. Below is my maven dependency list

[INFO] |  +- io.grpc:grpc-core:jar:1.2.0:compile
[INFO] |  |  +- com.google.guava:guava:jar:19.0:compile
[INFO] |  |  +- com.google.errorprone:error_prone_annotations:jar:2.0.11:compile
[INFO] |  |  +- com.google.code.findbugs:jsr305:jar:3.0.0:compile
[INFO] |  |  +- io.grpc:grpc-context:jar:1.2.0:compile
[INFO] |  |  \- com.google.instrumentation:instrumentation-api:jar:0.3.0:compile
[INFO] |  +- io.grpc:grpc-netty:jar:1.2.0:compile
[INFO] |  |  +- io.netty:netty-codec-http2:jar:4.1.8.Final:compile (version selected from constraint [4.1.8.Final,4.1.8.Final])
[INFO] |  |  |  +- io.netty:netty-codec-http:jar:4.1.8.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-codec:jar:4.1.8.Final:compile
[INFO] |  |  |  \- io.netty:netty-handler:jar:4.1.8.Final:compile
[INFO] |  |  |     \- io.netty:netty-buffer:jar:4.1.8.Final:compile
[INFO] |  |  |        \- io.netty:netty-common:jar:4.1.8.Final:compile
[INFO] |  |  \- io.netty:netty-handler-proxy:jar:4.1.8.Final:compile
[INFO] |  |     +- io.netty:netty-transport:jar:4.1.8.Final:compile
[INFO] |  |     |  \- io.netty:netty-resolver:jar:4.1.8.Final:compile
[INFO] |  |     \- io.netty:netty-codec-socks:jar:4.1.8.Final:compile
[INFO] |  +- io.grpc:grpc-protobuf:jar:1.2.0:compile
[INFO] |  |  +- com.google.protobuf:protobuf-java:jar:3.2.0:compile
[INFO] |  |  +- com.google.protobuf:protobuf-java-util:jar:3.2.0:compile
[INFO] |  |  |  \- com.google.code.gson:gson:jar:2.7:compile
[INFO] |  |  \- io.grpc:grpc-protobuf-lite:jar:1.2.0:compile
[INFO] |  +- io.grpc:grpc-stub:jar:1.2.0:compile
[INFO] |  +- net.javacrumbs.future-converter:future-converter-java8-guava:jar:1.1.0:compile
[INFO] |  |  +- net.javacrumbs.future-converter:future-converter-common:jar:1.1.0:compile
[INFO] |  |  +- net.javacrumbs.future-converter:future-converter-java8-common:jar:1.1.0:compile
[INFO] |  |  \- net.javacrumbs.future-converter:future-converter-guava-common:jar:1.1.0:compile
[INFO] |  +- io.netty:netty-tcnative-boringssl-static:jar:1.1.33.Fork26:compile

Debug logs:

    2018-04-23 11:38:28 DEBUG NativeLibraryLoader:71 - -Dio.netty.tmpdir: /opt/tomcat/temp (java.io.tmpdir)
2018-04-23 11:38:28 DEBUG NativeLibraryLoader:71 - -Dio.netty.native.workdir: /opt/tomcat/temp (io.netty.tmpdir)
2018-04-23 11:38:28 DEBUG NativeLibraryLoader:81 - Unable to load the library 'netty-tcnative-linux-x86_64', trying other loading mechanism.
java.lang.UnsatisfiedLinkError: no netty-tcnative-linux-x86_64 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    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:273)
    at java.security.AccessController.doPrivileged(Native Method)
    at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:264)
    at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:252)
    at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:199)
    at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:170)
    at io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:412)
    at io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:90)
    at io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:158)
    at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:139)
    at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109)    
2018-04-23 11:38:28 DEBUG NativeLibraryLoader:81 - Unable to load the library 'netty-tcnative-linux-x86_64', trying next name...
java.lang.UnsatisfiedLinkError: no netty-tcnative-linux-x86_64 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
    at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:259)
    at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:199)
    at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:170)
    at io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:412)
    at io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:90)
    at io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:158)
    at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:139)
    at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109
2018-04-23 11:38:28 DEBUG OpenSsl:91 - Failed to load netty-tcnative; OpenSslEngine will be unavailable, unless the application has already loaded the symbols by some other means. See http://netty.io/wiki/forked-tomcat-native.html for more information.
java.lang.IllegalArgumentException: Failed to load any of the given libraries: [netty-tcnative-linux-x86_64, netty-tcnative-linux-x86_64-fedora, netty-tcnative]
    at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:177)
    at io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:412)
    at io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:90)
    at io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:158)
    at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:139)
    at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109)

回答1:


I found out the solution, i upgraded netty-tcnative-boringssl-static to 2.0.7 and with this change all the other versions had to be upgraded (check the table in troubleshooting section in https://github.com/grpc/grpc-java/blob/master/SECURITY.md). This is the list i have used,

grpc-netty-1.9.1.jar
netty-3.2.2.Final.jar
netty-buffer-4.1.17.Final.jar
netty-codec-4.1.17.Final.jar
netty-codec-http-4.1.17.Final.jar
netty-codec-http2-4.1.17.Final.jar
netty-codec-socks-4.1.17.Final.jar
netty-common-4.1.17.Final.jar
netty-handler-4.1.17.Final.jar
netty-handler-proxy-4.1.17.Final.jar
netty-resolver-4.1.17.Final.jar
netty-tcnative-boringssl-static-2.0.7.Final.jar
netty-transport-4.1.17.Final.jar
grpc-context-1.9.1.jar
grpc-core-1.9.1.jar
grpc-protobuf-1.9.1.jar
grpc-protobuf-lite-1.9.1.jar
grpc-stub-1.9.1.jar
opencensus-contrib-grpc-metrics-0.10.0.jar



回答2:


This problem is fixed in more recent versions of netty-tcnative where its classes was move into another namespace (2.0.x series). So you should check which graph-java version supports these and upgrade.




回答3:


I solved a similar issue by upgrading from Java 8 to Java 11 as it has ALPN available by default.



来源:https://stackoverflow.com/questions/50014276/failed-to-load-any-of-the-given-libraries-netty-tcnative-linux-x86-64-netty-tc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!