IllegalArgumentException

IllegalArgumentException

本文介绍了谷歌云扳手java.lang.IllegalArgumentException:Jetty ALPN / NPN尚未正确配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Google云端Spanner的新手,并且对其进行了探索,我开始使用Google提供的文档。为了探索我们从数据操作开始的任何数据库,以及我所做的,我开始使用这里给出的简单Java应用程序将数据写入到扳手中。

我已经在下面的代码片段中显示的各个地方对驱动程序类进行了修改:

  public static void main(String [] args)抛出异常{
String path =File_Path;

SpannerOptions.Builder options = SpannerOptions.newBuilder()。setCredentials(GoogleCredentials.fromStream(new FileInputStream(path)));
options.setProjectId(Project_id);
Spanner spanner =(options.build())。getService();
尝试{
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);

$ / code>

现在,当我尝试执行代码时,最终出现以下错误:

 线程main中的异常java.lang.IllegalArgumentException:Jetty ALPN / NPN尚未正确配置。 
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)
位于io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109)
位于com.google.cloud.spanner.SpannerOptions $ NettyRpcChannelFactory .newSslContext(SpannerOptions.java:283)
,位于com.google.cloud.spanner.SpannerOptions $ NettyRpcChannelFactory.newChannel(SpannerOptions.java:274)
,位于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)
,位于com.google.cloud.spanner.SpannerOptions。< init>(SpannerOptions.java:43)
,位于com.google.cloud.spanner.SpannerOptions $ Builder.build (SpannerOptions .java:180)

在搜索此问题时,我一直建议添加一些依赖项,如:

 编译组:'org.eclipse.jetty.alpn',名称:'alpn-api',版本:'1.1.3 .v20160715'
编译组:'org.mortbay.jetty.alpn',名称:'jetty-alpn-agent',版本:'2.0.6'
编译组:'io.grpc',名称:'grpc-all',版本:'1.2.0'
编译组:'io.netty',名称:'netty-all',版本:'4.0.29.Final'
编译group:'org.eclipse.jetty.orbit',名称:'javax.servlet',版本:'3.0.0.v201112011016'

但面临同样的问题,我也使用Bigquery和其他GCP的功能相同的工作环境,并且除了 google-Spanner 以外,它们都可以正常工作,对此有任何建议。

问题的原因。正如在评论中所讨论的那样,实际的问题是另一个依赖关系
通过添加

 配置{
compile.exclude模块:'netty-all'
}

到build.gradle文件已解决此问题。



这里是我提出的关于这个错误的github问题的链接。 最终我发布了确切的问题这个由'@michaelbausor'解决。


I am new to the Google cloud Spanner and to explore it I started with documentation provided by 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.
I have made changes in driver class on respective places shown in following code snippet:

 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");
        }

Now, When I am trying to execute the code I end up with following error:

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)

while searching for this issue I have been suggest to add some dependencies like:

   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'

but facing same issue, I am also using Bigquery and other GCP's feature one same working environment and they all are working fine except google-Spanner, any suggestion on this is appreciated.
Thanks.

解决方案

Please read the comments on the question, @Mairbek Khadikov and my discussion on this conclude the actual reason of the issue. As discussed in comment the actual problem was with another dependencies.By adding

configurations {
    compile.exclude module: 'netty-all'
}

to the build.gradle file this issue has resolved.

Here is the link of github issue I raised regarding to this error. github issue where I posted exact issue eventually which I got to know and the resolution of that by, '@michaelbausor'.

这篇关于谷歌云扳手java.lang.IllegalArgumentException:Jetty ALPN / NPN尚未正确配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 23:56