Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用spring cloud gcp进行身份验证时遇到的问题_Java_Spring_Spring Boot_Spring Cloud Gcp_Spring Cloud Gcp Bigquery - Fatal编程技术网

Java 使用spring cloud gcp进行身份验证时遇到的问题

Java 使用spring cloud gcp进行身份验证时遇到的问题,java,spring,spring-boot,spring-cloud-gcp,spring-cloud-gcp-bigquery,Java,Spring,Spring Boot,Spring Cloud Gcp,Spring Cloud Gcp Bigquery,我需要通过spring配置类启动GCP依赖项,以便根据应用程序使用Google服务帐户。我无法在配置文件中使用它 以下是我尝试执行的代码: @Bean public CredentialsProvider credentialsProvider() throws IOException { return new DefaultCredentialsProvider(new CredentialsSupplier() { @Override public C

我需要通过spring配置类启动GCP依赖项,以便根据应用程序使用Google服务帐户。我无法在配置文件中使用它

以下是我尝试执行的代码:

@Bean
public CredentialsProvider credentialsProvider() throws IOException {
    return new DefaultCredentialsProvider(new CredentialsSupplier() {
        @Override
        public Credentials getCredentials() {
            Credentials credentials = new Credentials();
            credentials.setLocation(new InputStreamResource(new ByteArrayInputStream(DEFAULT_CREDENTIAL.getBytes())));
            return credentials;
        }
    });
}

@Bean
public GcpProjectIdProvider gcpProjectIdProvider() {
    GcpProjectIdProvider projectIdProvider = () -> DEFAULT_PROJECT_ID;

    return projectIdProvider;
}
这里有一个例外:

2020-09-14 15:07:39.558  WARN [,,,] 7660 --- [           main] .g.a.t.StackdriverTraceAutoConfiguration : Error when performing Stackdriver AsyncReporter health check.

java.lang.IllegalStateException: timeout waiting for onClose. timeoutMs=5000, resultSet=false
    at zipkin2.reporter.stackdriver.internal.AwaitableUnaryClientCallListener.await(AwaitableUnaryClientCallListener.java:49) ~[zipkin-sender-stackdriver-0.17.0.jar:na]
    at zipkin2.reporter.stackdriver.internal.UnaryClientCall.doExecute(UnaryClientCall.java:50) ~[zipkin-sender-stackdriver-0.17.0.jar:na]
    at zipkin2.Call$Base.execute(Call.java:380) ~[zipkin-2.21.1.jar:na]
    at zipkin2.reporter.stackdriver.StackdriverSender.check(StackdriverSender.java:183) ~[zipkin-sender-stackdriver-0.17.0.jar:na]
    at zipkin2.reporter.AsyncReporter$BoundedAsyncReporter.check(AsyncReporter.java:333) ~[zipkin-reporter-2.15.0.jar:na]
[apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] OUTBOUND HEADERS: streamId=5 headers=GrpcHttp2OutboundHeaders[:authority: cloudtrace.googleapis.com, :path: /google.devtools.cloudtrace.v2.TraceService/BatchWriteSpans, :method: POST, :scheme: https, content-type: application/grpc, te: trailers, user-agent: Spring/1.2.3.RELEASE spring-cloud-gcp-trace/1.2.3.RELEASE grpc-java-netty/1.28.1, grpc-accept-encoding: gzip, authorization: Bearer ya29.c.KqUB3AcUTYHPqCBgXXztVV7zzWAW2Goh1mGJ5FYl_1g4kPPtWz12zcplCzNCTxON05gsZ8xHnnMXNLG2mk6SJ1TlFPg4PqF3CXBD-QPkf6_ML8BVFLth2hIQiIFPgapXH9MptWc0NgricW_6lVRvsKHwVjNKXDz5euCZqLGlned_OVHY95noE8v1bGcYa7oNwxuXzfsx5mrn_uuixYd-Dgbh4B86VpB8] streamDependency=0 weight=16 exclusive=false padding=0 endStream=false
    [apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] OUTBOUND DATA: streamId=5 padding=0 endStream=true length=644 bytes=000000027f0a2670726f6a656374732f696e732d63726f73732d696e746567726174696f6e2d6170692d64657612d4040a6570726f6a656374732f696e732d63...
    [apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] INBOUND HEADERS: streamId=5 headers=GrpcHttp2ResponseHeaders[:status: 200, content-type: application/grpc, date: Mon, 14 Sep 2020 18:09:29 GMT, alt-svc: h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"] padding=0 endStream=false
    [apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] INBOUND HEADERS: streamId=5 headers=GrpcHttp2ResponseHeaders[grpc-status: 7, grpc-message: The caller does not have permission] padding=0 endStream=true
    [apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] INBOUND PING: ack=false bytes=2
    [apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] OUTBOUND PING: ack=true bytes=2
    [apiName: LogDemo] - WARN AsyncReporter$BoundedAsyncReporter: Spans were dropped due to exceptions. All subsequent errors will be logged at FINE level.
    [apiName: LogDemo] - WARN AsyncReporter$BoundedAsyncReporter: Dropped 1 spans due to StatusRuntimeException(PERMISSION_DENIED: The caller does not have permission)
    io.grpc.StatusRuntimeException: PERMISSION_DENIED: The caller does not have permission
        at io.grpc.Status.asRuntimeException(Status.java:533) ~[grpc-api-1.28.1.jar:1.28.1]
        at zipkin2.reporter.stackdriver.internal.AwaitableUnaryClientCallListener.onClose(AwaitableUnaryClientCallListener.java:100) ~[zipkin-sender-stackdriver-0.17.0.jar:na]
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ClientCallImpl.access$500(ClientCallImpl.java:66) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:689) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$900(ClientCallImpl.java:577) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:751) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:740) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) ~[grpc-core-1.28.1.jar:1.28.1]
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
初始化失败后,应用程序能够运行,当我尝试发送记录时,出现以下异常:

2020-09-14 15:07:39.558  WARN [,,,] 7660 --- [           main] .g.a.t.StackdriverTraceAutoConfiguration : Error when performing Stackdriver AsyncReporter health check.

java.lang.IllegalStateException: timeout waiting for onClose. timeoutMs=5000, resultSet=false
    at zipkin2.reporter.stackdriver.internal.AwaitableUnaryClientCallListener.await(AwaitableUnaryClientCallListener.java:49) ~[zipkin-sender-stackdriver-0.17.0.jar:na]
    at zipkin2.reporter.stackdriver.internal.UnaryClientCall.doExecute(UnaryClientCall.java:50) ~[zipkin-sender-stackdriver-0.17.0.jar:na]
    at zipkin2.Call$Base.execute(Call.java:380) ~[zipkin-2.21.1.jar:na]
    at zipkin2.reporter.stackdriver.StackdriverSender.check(StackdriverSender.java:183) ~[zipkin-sender-stackdriver-0.17.0.jar:na]
    at zipkin2.reporter.AsyncReporter$BoundedAsyncReporter.check(AsyncReporter.java:333) ~[zipkin-reporter-2.15.0.jar:na]
[apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] OUTBOUND HEADERS: streamId=5 headers=GrpcHttp2OutboundHeaders[:authority: cloudtrace.googleapis.com, :path: /google.devtools.cloudtrace.v2.TraceService/BatchWriteSpans, :method: POST, :scheme: https, content-type: application/grpc, te: trailers, user-agent: Spring/1.2.3.RELEASE spring-cloud-gcp-trace/1.2.3.RELEASE grpc-java-netty/1.28.1, grpc-accept-encoding: gzip, authorization: Bearer ya29.c.KqUB3AcUTYHPqCBgXXztVV7zzWAW2Goh1mGJ5FYl_1g4kPPtWz12zcplCzNCTxON05gsZ8xHnnMXNLG2mk6SJ1TlFPg4PqF3CXBD-QPkf6_ML8BVFLth2hIQiIFPgapXH9MptWc0NgricW_6lVRvsKHwVjNKXDz5euCZqLGlned_OVHY95noE8v1bGcYa7oNwxuXzfsx5mrn_uuixYd-Dgbh4B86VpB8] streamDependency=0 weight=16 exclusive=false padding=0 endStream=false
    [apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] OUTBOUND DATA: streamId=5 padding=0 endStream=true length=644 bytes=000000027f0a2670726f6a656374732f696e732d63726f73732d696e746567726174696f6e2d6170692d64657612d4040a6570726f6a656374732f696e732d63...
    [apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] INBOUND HEADERS: streamId=5 headers=GrpcHttp2ResponseHeaders[:status: 200, content-type: application/grpc, date: Mon, 14 Sep 2020 18:09:29 GMT, alt-svc: h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"] padding=0 endStream=false
    [apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] INBOUND HEADERS: streamId=5 headers=GrpcHttp2ResponseHeaders[grpc-status: 7, grpc-message: The caller does not have permission] padding=0 endStream=true
    [apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] INBOUND PING: ack=false bytes=2
    [apiName: LogDemo] - DEBUG NettyClientHandler: [id: 0x2ae6c763, L:/192.168.1.107:57933 - R:cloudtrace.googleapis.com/172.217.29.42:443] OUTBOUND PING: ack=true bytes=2
    [apiName: LogDemo] - WARN AsyncReporter$BoundedAsyncReporter: Spans were dropped due to exceptions. All subsequent errors will be logged at FINE level.
    [apiName: LogDemo] - WARN AsyncReporter$BoundedAsyncReporter: Dropped 1 spans due to StatusRuntimeException(PERMISSION_DENIED: The caller does not have permission)
    io.grpc.StatusRuntimeException: PERMISSION_DENIED: The caller does not have permission
        at io.grpc.Status.asRuntimeException(Status.java:533) ~[grpc-api-1.28.1.jar:1.28.1]
        at zipkin2.reporter.stackdriver.internal.AwaitableUnaryClientCallListener.onClose(AwaitableUnaryClientCallListener.java:100) ~[zipkin-sender-stackdriver-0.17.0.jar:na]
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ClientCallImpl.access$500(ClientCallImpl.java:66) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:689) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$900(ClientCallImpl.java:577) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:751) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:740) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.28.1.jar:1.28.1]
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) ~[grpc-core-1.28.1.jar:1.28.1]
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]