在使用Google Pubsub列出主题时获取异常,我的网络应用程序正在tomcat上运行。
public static List<String> listTopics(GcpCredentials gcCredentials, String project) throws GCPException, IOException
{
List<String> topics = new ArrayList<>();
TopicAdminClient client = getTopicClient(gcCredentials);
ProjectName projectName = ProjectName.create(project);
ListTopicsPagedResponse response = client.listTopics(projectName);
for (Topic topic :response.iterateAll())
{
topics.add(topic.getNameAsTopicName().getTopic());
}
return topics;
}`
例外:
java.lang.IllegalArgumentException:Jetty ALPN / NPN配置不正确。
在io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:174) 在io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:151) 在io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:139) 在io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109) 在io.grpc.netty.NettyChannelBuilder.createProtocolNegotiatorByType(NettyChannelBuilder.java:335) 在io.grpc.netty.NettyChannelBuilder.createProtocolNegotiator(NettyChannelBuilder.java:308) at io.grpc.netty.NettyChannelBuilder $ NettyTransportFactory $ DynamicNettyTransportParams.getProtocolNegotiator(NettyChannelBuilder.java:499) 在io.grpc.netty.NettyChannelBuilder $ NettyTransportFactory.newClientTransport(NettyChannelBuilder.java:448) at io.grpc.internal.CallCredentialsApplyingTransportFactory.newClientTransport(CallCredentialsApplyingTransportFactory.java:61) at io.grpc.internal.InternalSubchannel.startNewTransport(InternalSubchannel.java:209) 在io.grpc.internal.InternalSubchannel.obtainActiveTransport(InternalSubchannel.java:186) at io.grpc.internal.ManagedChannelImpl $ SubchannelImplImpl.obtainActiveTransport(ManagedChannelImpl.java:806) 在io.grpc.internal.GrpcUtil.getTransportFromPickResult(GrpcUtil.java:568) 在io.grpc.internal.DelayedClientTransport.reprocess(DelayedClientTransport.java:296) at io.grpc.internal.ManagedChannelImpl $ LbHelperImpl $ 5.run(ManagedChannelImpl.java:724) 在io.grpc.internal.ChannelExecutor.drain(ChannelExecutor.java:87) 在io.grpc.internal.ManagedChannelImpl $ LbHelperImpl.runSerialized(ManagedChannelImpl.java:715) at io.grpc.internal.ManagedChannelImpl $ NameResolverListenerImpl.onUpdate(ManagedChannelImpl.java:752) at io.grpc.internal.DnsNameResolver $ 1.run(DnsNameResolver.java:174) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:1)
我已经使用Netty 4.1.15.Final观察到了这个问题,但是没有使用4.1.13.Final。检查您的传递依赖项。即Spring Boot引用Netty。
我添加到POM以使其与Spanner API版本0.22.0-beta一起使用:
<properties>
<v.netty>4.1.13.Final</v.netty>
</properties>
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http2</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler-proxy</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-socks</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>${v.netty}</version>
</dependency>
</dependencies>
</dependencyManagement>
如果问题仍然存在,或者它不是一个选项,请使用适当的bootclasspath条目运行JVM,如:
java -Xbootclasspath/p:/tmp/alpn-boot-8.1.11.v20170118.jar -cp ...
请务必将/tmp/alpn-boot-8.1.11.v20170118.jar
替换为与您的JVM版本相匹配的alpn jar的位置,如本页所示:https://www.eclipse.org/jetty/documentation/9.4.x/alpn-chapter.html
答案 1 :(得分:-1)
github上有一个可能的解决方案:&#34; Exception when configuring SSL: "Jetty ALPN/NPN has not been properly configured.&#34;
建议的步骤,引用上述文件:
1)编辑catalina.sh /usr/local/Cellar/tomcat/8.5.3/libexec/bin/catalina.sh
2)在第103行,添加以下内容 CATALINA_OPTS =&#34; -javaagent:/Library/Tomcat/lib/jetty-alpn-agent-2.0.6.jar"
3)重启tomcat ../bin/shutdown.sh ../ bin / startup.sh