google Cloud spanner java.lang.IllegalArgumentException: Jetty ALPN/NPN 尚未正确配置
google Cloud spanner java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured
我是 Google Cloud Spanner 的新手,为了探索它,我从 google Here. To explore any database we start with data operations and the same I did, I started with writing data to the spanner using simple java application given here https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/spanner/cloud-client/src/main/java/com/example/spanner/SpannerSample.java 提供的文档开始。
我在驱动程序 class 中对以下代码片段中显示的相应位置进行了更改:
public static void main(String[] args) throws Exception {
String path = "File_Path";
SpannerOptions.Builder options = SpannerOptions.newBuilder().setCredentials(GoogleCredentials.fromStream(new FileInputStream(path)));
options.setProjectId("Project_id");
Spanner spanner = (options.build()).getService();
try {
DatabaseId db = DatabaseId.of("project_id", "spannerInstance", "Database_name");
DatabaseClient dbClient = spanner.getDatabaseClient(db);
run(dbClient);
} finally {
spanner.closeAsync().get();
}
System.out.println("Closed client");
}
现在,当我尝试执行代码时,我遇到了以下错误:
Exception in thread "main" java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured.
at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:174)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:151)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:139)
at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109)
at com.google.cloud.spanner.SpannerOptions$NettyRpcChannelFactory.newSslContext(SpannerOptions.java:283)
at com.google.cloud.spanner.SpannerOptions$NettyRpcChannelFactory.newChannel(SpannerOptions.java:274)
at com.google.cloud.spanner.SpannerOptions.createChannel(SpannerOptions.java:253)
at com.google.cloud.spanner.SpannerOptions.createChannels(SpannerOptions.java:240)
at com.google.cloud.spanner.SpannerOptions.<init>(SpannerOptions.java:89)
at com.google.cloud.spanner.SpannerOptions.<init>(SpannerOptions.java:43)
at com.google.cloud.spanner.SpannerOptions$Builder.build(SpannerOptions.java:180)
在搜索此问题时,有人建议我添加一些依赖项,例如:
compile group: 'org.eclipse.jetty.alpn', name: 'alpn-api', version: '1.1.3.v20160715'
compile group: 'org.mortbay.jetty.alpn', name: 'jetty-alpn-agent', version: '2.0.6'
compile group: 'io.grpc', name: 'grpc-all', version: '1.2.0'
compile group: 'io.netty', name: 'netty-all', version: '4.0.29.Final'
compile group: 'org.eclipse.jetty.orbit', name: 'javax.servlet', version: '3.0.0.v201112011016'
但面临同样的问题,我也在使用 Bigquery 和其他 GCP 的功能,在一个相同的工作环境中,它们都工作正常,除了 google-Spanner,任何建议对此表示赞赏。
谢谢。
请阅读问题的评论,@Mairbek Khadikov 和我对此的讨论总结了问题的实际原因。正如评论中所讨论的,实际问题出在另一个依赖项上。
通过添加
configurations {
compile.exclude module: 'netty-all'
}
此问题已解决的 build.gradle 文件。
这是我针对此错误提出的 github 问题的 link。 github issue 我最终发布了我知道的确切问题以及由“@michaelbausor”解决的问题。
我是 Google Cloud Spanner 的新手,为了探索它,我从 google Here. To explore any database we start with data operations and the same I did, I started with writing data to the spanner using simple java application given here https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/spanner/cloud-client/src/main/java/com/example/spanner/SpannerSample.java 提供的文档开始。
我在驱动程序 class 中对以下代码片段中显示的相应位置进行了更改:
public static void main(String[] args) throws Exception {
String path = "File_Path";
SpannerOptions.Builder options = SpannerOptions.newBuilder().setCredentials(GoogleCredentials.fromStream(new FileInputStream(path)));
options.setProjectId("Project_id");
Spanner spanner = (options.build()).getService();
try {
DatabaseId db = DatabaseId.of("project_id", "spannerInstance", "Database_name");
DatabaseClient dbClient = spanner.getDatabaseClient(db);
run(dbClient);
} finally {
spanner.closeAsync().get();
}
System.out.println("Closed client");
}
现在,当我尝试执行代码时,我遇到了以下错误:
Exception in thread "main" java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured.
at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:174)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:151)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:139)
at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109)
at com.google.cloud.spanner.SpannerOptions$NettyRpcChannelFactory.newSslContext(SpannerOptions.java:283)
at com.google.cloud.spanner.SpannerOptions$NettyRpcChannelFactory.newChannel(SpannerOptions.java:274)
at com.google.cloud.spanner.SpannerOptions.createChannel(SpannerOptions.java:253)
at com.google.cloud.spanner.SpannerOptions.createChannels(SpannerOptions.java:240)
at com.google.cloud.spanner.SpannerOptions.<init>(SpannerOptions.java:89)
at com.google.cloud.spanner.SpannerOptions.<init>(SpannerOptions.java:43)
at com.google.cloud.spanner.SpannerOptions$Builder.build(SpannerOptions.java:180)
在搜索此问题时,有人建议我添加一些依赖项,例如:
compile group: 'org.eclipse.jetty.alpn', name: 'alpn-api', version: '1.1.3.v20160715'
compile group: 'org.mortbay.jetty.alpn', name: 'jetty-alpn-agent', version: '2.0.6'
compile group: 'io.grpc', name: 'grpc-all', version: '1.2.0'
compile group: 'io.netty', name: 'netty-all', version: '4.0.29.Final'
compile group: 'org.eclipse.jetty.orbit', name: 'javax.servlet', version: '3.0.0.v201112011016'
但面临同样的问题,我也在使用 Bigquery 和其他 GCP 的功能,在一个相同的工作环境中,它们都工作正常,除了 google-Spanner,任何建议对此表示赞赏。
谢谢。
请阅读问题的评论,@Mairbek Khadikov 和我对此的讨论总结了问题的实际原因。正如评论中所讨论的,实际问题出在另一个依赖项上。 通过添加
configurations {
compile.exclude module: 'netty-all'
}
此问题已解决的 build.gradle 文件。
这是我针对此错误提出的 github 问题的 link。 github issue 我最终发布了我知道的确切问题以及由“@michaelbausor”解决的问题。