gpt4 book ai didi

java - 非法参数异常 : Jetty ALPN/NPN has not been properly configured

转载 作者:太空宇宙 更新时间:2023-11-03 13:34:30 25 4
gpt4 key购买 nike

我正在尝试在 google api 中使用 google vision,但是我遇到了以下问题:

jun 07, 2017 8:50:00 AM io.grpc.internal.ChannelExecutor drain ADVERTÊNCIA: Runnable threw exception in ChannelExecutor 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 io.grpc.netty.NettyChannelBuilder.createProtocolNegotiatorByType(NettyChannelBuilder.java:335) at io.grpc.netty.NettyChannelBuilder.createProtocolNegotiator(NettyChannelBuilder.java:308) at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory$DynamicNettyTransportParams.getProtocolNegotiator(NettyChannelBuilder.java:499) at 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) at io.grpc.internal.InternalSubchannel.obtainActiveTransport(InternalSubchannel.java:186) at io.grpc.internal.ManagedChannelImpl$SubchannelImplImpl.obtainActiveTransport(ManagedChannelImpl.java:806) at io.grpc.internal.GrpcUtil.getTransportFromPickResult(GrpcUtil.java:568) at io.grpc.internal.DelayedClientTransport.reprocess(DelayedClientTransport.java:296) at io.grpc.internal.ManagedChannelImpl$LbHelperImpl$5.run(ManagedChannelImpl.java:724) at io.grpc.internal.ChannelExecutor.drain(ChannelExecutor.java:87) at 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) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

我正在尝试运行 api 自己的示例代码,如下所示:

public class QuickstartSample {
public static void main(String... args) throws Exception {
// Instantiates a client
ImageAnnotatorClient vision = ImageAnnotatorClient.create();

// The path to the image file to annotate
String fileName = "./resources/wakeupcat.jpg";

// Reads the image file into memory
Path path = Paths.get(fileName);
byte[] data = Files.readAllBytes(path);
ByteString imgBytes = ByteString.copyFrom(data);

// Builds the image annotation request
List<AnnotateImageRequest> requests = new ArrayList<>();
Image img = Image.newBuilder().setContent(imgBytes).build();
Feature feat = Feature.newBuilder().setType(Type.LABEL_DETECTION).build();
AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
requests.add(request);

// Performs label detection on the image file
BatchAnnotateImagesResponse response = vision.batchAnnotateImages(requests);
List<AnnotateImageResponse> responses = response.getResponsesList();

for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
System.out.printf("Error: %s\n", res.getError().getMessage());
return;
}

for (EntityAnnotation annotation : res.getLabelAnnotationsList()) {
annotation.getAllFields().forEach((k, v) -> System.out.printf("%s : %s\n", k, v.toString()));
}
}
}
}

我正在使用以下依赖项:

    <dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-vision</artifactId>
<version>v1-rev357-1.22.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-vision</artifactId>
<version>0.17.2-beta</version>
</dependency>

有人遇到过这个问题吗?

最佳答案

我实际上发现要运行 api,您必须在 Web 上下文中并且还在 Jetty 服务器上运行应用程序

关于java - 非法参数异常 : Jetty ALPN/NPN has not been properly configured,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44411988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com