您使用的是什么版本的gRPC?
1.13.1
我正在使用java 8构建一个可执行的jar。下面是java版本:
$ /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/bin/java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-2~14.04-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
我使用gradle 3.4.1生成jar如下:/opt/gradle-3.4.1/bin/gradle jar -Dorg.gradle.java.home=/usr/lib/jvm/java-1.8.0-openjdk-amd64/
以下是模块级build.gradle文件中定义的依赖项:
dependencies {
compile files("$TOOLCHAIN_VERSION_DIR/lib/commons-io-2.6.jar")
compile files("$TOOLCHAIN_VERSION_DIR/lib/grpc-all.jar")
compile files("$TOOLCHAIN_VERSION_DIR/lib/java-protobuf.jar")
compile files("$TOOLCHAIN_VERSION_DIR/lib/jetty.jar")
compile files("$TOOLCHAIN_VERSION_DIR/lib/log4j-core-2.8.jar")
compile files("$TOOLCHAIN_VERSION_DIR/lib/log4j-slf4j-impl-2.8.jar")
compile files("$TOOLCHAIN_VERSION_DIR/lib/netty-tcnative-boringssl-static-2.0.20.Final.jar")
compile files("$TOOLCHAIN_VERSION_DIR/lib/netty-tcnative-2.0.20.Final.jar")
compile files("$TOOLCHAIN_VERSION_DIR/lib/picocli-3.8.2.jar")
compile group: 'com.google.guava', name: 'guava', version: '20.0'
compile files("$TOOLCHAIN_VERSION_DIR/lib/javassist-3.19.0-GA.jar")
compile project(':annotation')
}
构建完成后,我在AIX7.2机器上运行jar,如下所示:/usr/java8_64/jre/bin/java -jar agent-1.0.jar
AIX机器上的java版本如下:
$ /usr/java8_64/jre/bin/java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 8.0.5.26 - pap6480sr5fp26-20181115_03(SR5 FP26))
IBM J9 VM (build 2.9, JRE 1.8.0 AIX ppc64-64-Bit Compressed References 20181106_401576 (JIT enabled, AOT enabled)
OpenJ9 - fde1d6f
OMR - d8c3617
IBM - 5c4a9f0)
JCL - 20181022_01 based on Oracle jdk8u191-b26
但我在运行时收到以下错误:
Feb 17, 2019 3:11:33 AM io.grpc.netty.GrpcSslContexts defaultSslProvider
INFO: netty-tcnative unavailable (this may be normal)
java.lang.IllegalArgumentException: Failed to load any of the given libraries: [netty_tcnative_aix_ppc_64, netty_tcnative_ppc_64, netty_tcnative]
at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:93)
at io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:430)
at io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:97)
at io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:242)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:171)
at io.grpc.netty.GrpcSslContexts.forServer(GrpcSslContexts.java:151)
at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:456)
at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:55)
at com.ankit.agents.AgentMain.<init>(AgentMain.java:91)
at com.ankit.agents.AgentMain.main(AgentMain.java:132)
Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative_aix_ppc_64
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:205)
at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:85)
... 9 more
Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative_aix_ppc_64.a
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161)
... 10 more
Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative_aix_ppc_64 (Not found in java.library.path)
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
at java.lang.System.loadLibrary(System.java:565)
at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:243)
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:124)
... 10 more
Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative_aix_ppc_64 (Not found in java.library.path)
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
at java.lang.System.loadLibrary(System.java:565)
at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:263)
at java.security.AccessController.doPrivileged(AccessController.java:647)
at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:255)
at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:233)
... 11 more
Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative_ppc_64
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:205)
at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:85)
... 9 more
Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative_ppc_64.a
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161)
... 10 more
Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative_ppc_64 (Not found in java.library.path)
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
at java.lang.System.loadLibrary(System.java:565)
at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:243)
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:124)
... 10 more
Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative_ppc_64 (Not found in java.library.path)
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
at java.lang.System.loadLibrary(System.java:565)
at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:263)
at java.security.AccessController.doPrivileged(AccessController.java:647)
at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:255)
at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:233)
... 11 more
Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:205)
at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:85)
... 9 more
Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative.a
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161)
... 10 more
Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative (Not found in java.library.path)
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
at java.lang.System.loadLibrary(System.java:565)
at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:243)
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:124)
... 10 more
Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative (Not found in java.library.path)
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
at java.lang.System.loadLibrary(System.java:565)
at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:263)
at java.security.AccessController.doPrivileged(AccessController.java:647)
at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:255)
at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:233)
... 11 more
Feb 17, 2019 3:11:33 AM io.grpc.netty.GrpcSslContexts defaultSslProvider
INFO: Conscrypt not found (this may be normal)
Feb 17, 2019 3:11:33 AM io.grpc.netty.GrpcSslContexts defaultSslProvider
INFO: Jetty ALPN unavailable (this may be normal)
java.lang.ClassNotFoundException: org.eclipse.jetty.alpn.ALPN
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:403)
at io.grpc.netty.JettyTlsUtil.isJettyAlpnConfigured(JettyTlsUtil.java:64)
at io.grpc.netty.JettyTlsUtil.getJettyAlpnUnavailabilityCause(JettyTlsUtil.java:75)
at io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:255)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:171)
at io.grpc.netty.GrpcSslContexts.forServer(GrpcSslContexts.java:151)
at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:456)
at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:55)
at com.ankit.agents.AgentMain.<init>(AgentMain.java:91)
at com.ankit.agents.AgentMain.main(AgentMain.java:132)
Exception in thread "main" java.lang.IllegalStateException: Could not find TLS ALPN provider; no working netty-tcnative, Conscrypt, or Jetty NPN/ALPN available
at io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:256)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:171)
at io.grpc.netty.GrpcSslContexts.forServer(GrpcSslContexts.java:151)
at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:456)
at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:55)
at com.ankit.agents.AgentMain.<init>(AgentMain.java:91)
at com.ankit.agents.AgentMain.main(AgentMain.java:132)
然而,它在Ubuntu机器上运行良好。我运行jar如下:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/bin/java -jar agent-1.0.jar
这里的java版本是:
$ /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/bin/java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-2~14.04-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
这里的问题是什么,如何解决?
4条答案
按热度按时间kpbwa7wx1#
可能是:https://github.com/grpc/grpc-java/blob/master/SECURITY.md#tls-with-netty-tcnative-on-boringssl
我在我的build.gradle中添加了
runtime 'io.netty:netty-tcnative-boringssl-static:2.0.25.Final'
,它工作了6yjfywim2#
我在另一个类似的问题中也回答了这个问题,这个问题也可能是因为高山基地的形象incompaibility,如果你正在使用它。
“看起来你正在使用基本图像作为alpine,它实际上不支持gRPC,你需要在你的应用程序中添加gcompact apk。所以,你可以做的是:使用docker:“
a9wyjsp73#
在我的例子中,只要将Java版本从8更新到14就解决了这个问题(版本11也应该没问题)。
如果您使用的是Intellij,请确保您的版本更改工作正常。
okxuctiv4#
我已经升级到Java 17,这个错误已经解决了。