java.lang.ClassNotFoundException:org / eclipse / jetty / alpn / ALPN

时间:2018-01-24 17:37:20

标签: java firebase google-cloud-firestore

我正在使用Java学习Firestore并尝试了Firebase官方网站https://firebase.google.com/docs/firestore/quickstart提供的示例代码

这是一个非常简单的代码

import com.google.auth.oauth2.GoogleCredentials; import 
com.google.cloud.firestore.Firestore;

import com.google.firebase.FirebaseApp; import 
com.google.firebase.FirebaseOptions;

// Use a service account InputStream serviceAccount = new 
FileInputStream("path/to/serviceAccount.json"); GoogleCredentials 
credentials = GoogleCredentials.fromStream(serviceAccount); 
FirebaseOptions options = new FirebaseOptions.Builder() 
.setCredentials(credentials) .build(); 
FirebaseApp.initializeApp(options);

Firestore db = FirestoreClient.getFirestore();

在获取db对象时,我收到错误

Caused by: java.io.IOException: java.lang.IllegalArgumentException: ALPN is not configured properly. See https://github.com/grpc/grpc-java/blob/master/SECURITY.md#troubleshooting for more information.
at com.google.cloud.firestore.spi.v1beta1.GrpcFirestoreRpc.<init>(GrpcFirestoreRpc.java:138)
at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:71)
... 15 more
Caused by: java.lang.IllegalArgumentException: ALPN is not configured properly. See https://github.com/grpc/grpc-java/blob/master/SECURITY.md#troubleshooting for more information.
at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:163)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:136)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:124)
at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:94)
at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory$DefaultNettyTransportCreationParamsFilterFactory.<init>(NettyChannelBuilder.java:546)
at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory$DefaultNettyTransportCreationParamsFilterFactory.<init>(NettyChannelBuilder.java:539)
at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory.<init>(NettyChannelBuilder.java:477)
at io.grpc.netty.NettyChannelBuilder.buildTransportFactory(NettyChannelBuilder.java:325)
at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:342)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:185)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:142)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:134)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:129)
at com.google.cloud.firestore.spi.v1beta1.GrpcFirestoreRpc.<init>(GrpcFirestoreRpc.java:124)
... 16 more
Caused by: java.lang.ClassNotFoundException: org/eclipse/jetty/alpn/ALPN
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at io.grpc.netty.JettyTlsUtil.isJettyAlpnConfigured(JettyTlsUtil.java:34)
at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:153)
... 29 more

Process finished with exit code 1

我的IDE是intellij,我正在运行它,org / eclipse / jetty / alpn / ALPN在外部库下的类路径中可见

alpn-api-1.1.3.v20160715.jar
ALPN

有人遇到类似的问题吗?

提前致谢。

2 个答案:

答案 0 :(得分:1)

我在FireStore项目中遇到了同样的问题:ALPN is not configured properly&gt; java.lang.ClassNotFoundException: org/eclipse/jetty/alpn/ALPN。几个月前项目工作正常,我对这个问题非常失望。

该消息非常具有误导性,并且远非我的情况下的根本原因。我尝试使用Java x32netty-tcnative-boringssl-static运行项目(由grpc使用,由firestore API使用)仅针对&#39; x64&#39; (您可以在netty-tcnative-boringssl-static-2.0.8.Final.jar/META-INF/native/中查看支持的原生代码)。在调试过程中,我发现root cause问题被静默抑制,并且无法加载&x; x86版本的netty_tcnative_windows _ *。dll&#39;代码尝试使用ALPN运行,但这需要额外的项目启动自定义。

所以......正确的问题是 - 不要在Jdk x32上运行Firestore项目

答案 1 :(得分:0)

我意识到我错误地生成了我的Google服务帐户密钥。我已经跟进了Firestore文档并生成了正确的密钥