无法加载任何给定的库:[netty-tcnative-linux-x86_64,netty-tcnative]

时间:2018-04-25 04:52:04

标签: tomcat netty grpc-java

我在tomcat容器中部署了一个web应用程序,并使用了grpc-netty(1.2.0)和netty-tcnative-boringssl-static:jar:1.1.33.Fork26。

当我打开调试日志时,它会告诉“java.lang.IllegalArgumentException:无法加载任何给定的库:[netty-tcnative-linux-x86_64,netty-tcnative-linux-x86_64-fedora,netty-tcnative ]“然后出现错误消息”java.lang.IllegalArgumentException:Jetty ALPN / NPN尚未正确配置。“。

我已经浏览了https://github.com/grpc/grpc-java/blob/master/SECURITY.md的问题排查部分并验证了我的netty版本,这看起来没问题。下面是我的maven依赖列表

[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

调试日志:

    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)

3 个答案:

答案 0 :(得分:2)

我找到了解决方案,我将netty-tcnative-boringssl-static升级到2.0.7,并且通过此更改,所有其他版本都必须升级(请查看https://github.com/grpc/grpc-java/blob/master/SECURITY.md中的故障排除部分中的表格)。这是我用过的清单,

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

答案 1 :(得分:1)

此问题在更新版本的netty-tcnative中得到修复,其中的类移动到另一个命名空间(2.0.x系列)。所以你应该检查哪个graph-java版本支持这些并升级。

答案 2 :(得分:0)

我通过从Java 8升级到Java 11来解决了类似的问题,因为默认情况下它具有ALPN。