在数据流 2.3.0 中使用 google 扳手
Using google spanner in dataflow 2.3.0
我正在尝试写一些来自 google pub/sub 的消息给 spanner。写入 bigtable 有效,因此在基础层面上没有遗漏任何内容。
我已经升级到 google-cloud-dataflow-java-sdk-all
v2.3.0,其中包括 SpannerIO 接收器。
我基本上是按照 API docs of SpannerIO.
的例子写的
但是,我遇到了异常 internal_static_google_rpc_LocalizedMessage_fieldAccessorTable
完整堆栈跟踪:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project second-dataflow: An exception occured while executing the Java class. internal_static_google_rpc_LocalizedMessage_fieldAccessorTable
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. internal_static_google_rpc_LocalizedMessage_fieldAccessorTable
at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:339)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.lang.NoSuchFieldError: internal_static_google_rpc_LocalizedMessage_fieldAccessorTable
at com.google.rpc.LocalizedMessage.internalGetFieldAccessorTable (LocalizedMessage.java:87)
at com.google.protobuf.GeneratedMessageV3.getDescriptorForType (GeneratedMessageV3.java:121)
at io.grpc.protobuf.ProtoUtils.keyForProto (ProtoUtils.java:126)
at com.google.cloud.spanner.spi.v1.SpannerErrorInterceptor.<clinit> (SpannerErrorInterceptor.java:47)
at com.google.cloud.spanner.spi.v1.GrpcSpannerRpc.<init> (GrpcSpannerRpc.java:128)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerRpcFactory.create (SpannerOptions.java:70)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerRpcFactory.create (SpannerOptions.java:65)
at com.google.cloud.ServiceOptions.getRpc (ServiceOptions.java:443)
at com.google.cloud.spanner.SpannerOptions.getSpannerRpcV1 (SpannerOptions.java:315)
at com.google.cloud.spanner.SpannerImpl.<init> (SpannerImpl.java:138)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerFactory.create (SpannerOptions.java:60)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerFactory.create (SpannerOptions.java:55)
at com.google.cloud.ServiceOptions.getService (ServiceOptions.java:430)
at org.apache.beam.sdk.io.gcp.spanner.SpannerConfig.connectToSpanner (SpannerConfig.java:155)
at com.crypto20.DeveloperSubscription.main (DeveloperSubscription.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:748)
指定 withProjectId()
并不能解决问题。
也没有升级所有依赖项,包括传递引入的依赖项 - 除非我犯了一个错误(我不习惯数据流的内部结构以及每个依赖项的作用)。更新依赖项后,甚至无法暂存已编译的项目。
我怀疑有一个特定的依赖项需要更新,我尝试了各种组合,但无济于事。
更新:
我尝试过的其中一件事是将 grpc-google-common-protos
固定到 0.1.9
甚至是最新的 1.2.0
.
如果我这样做,甚至无法上传管道,因为我在上传前遇到以下异常:
Mar 12, 2018 7:40:22 AM org.apache.beam.runners.dataflow.util.PackageUtil stageClasspathElements
INFO: Uploading 120 files from PipelineOptions.filesToStage to staging location to prepare for execution.
[WARNING]
java.lang.RuntimeException: Error while staging packages
at org.apache.beam.runners.dataflow.util.PackageUtil.stageClasspathElements (PackageUtil.java:396)
at org.apache.beam.runners.dataflow.util.PackageUtil.stageClasspathElements (PackageUtil.java:272)
at org.apache.beam.runners.dataflow.util.GcsStager.stageFiles (GcsStager.java:76)
at org.apache.beam.runners.dataflow.util.GcsStager.stageDefaultFiles (GcsStager.java:64)
at org.apache.beam.runners.dataflow.DataflowRunner.run (DataflowRunner.java:661)
at org.apache.beam.runners.dataflow.DataflowRunner.run (DataflowRunner.java:174)
at org.apache.beam.sdk.Pipeline.run (Pipeline.java:311)
at org.apache.beam.sdk.Pipeline.run (Pipeline.java:297)
at com.crypto20.DeveloperSubscription.main (DeveloperSubscription.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:748)
Caused by: java.io.IOException: Error executing batch GCS request
at org.apache.beam.sdk.util.GcsUtil.executeBatches (GcsUtil.java:610)
at org.apache.beam.sdk.util.GcsUtil.getObjects (GcsUtil.java:341)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.matchNonGlobs (GcsFileSystem.java:216)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.match (GcsFileSystem.java:85)
at org.apache.beam.sdk.io.FileSystems.match (FileSystems.java:123)
at org.apache.beam.sdk.io.FileSystems.matchSingleFileSpec (FileSystems.java:188)
at org.apache.beam.runners.dataflow.util.PackageUtil.alreadyStaged (PackageUtil.java:159)
at org.apache.beam.runners.dataflow.util.PackageUtil.stagePackageSynchronously (PackageUtil.java:183)
at org.apache.beam.runners.dataflow.util.PackageUtil.lambda$stagePackage (PackageUtil.java:173)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly (TrustedListenableFutureTask.java:111)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.InterruptibleTask.run (InterruptibleTask.java:58)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask.run (TrustedListenableFutureTask.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: com.google.api.client.http.HttpResponseException: 404 Not Found
Not Found
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.AbstractFuture.getDoneValue (AbstractFuture.java:500)
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.AbstractFuture.get (AbstractFuture.java:479)
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get (AbstractFuture.java:76)
at org.apache.beam.sdk.util.GcsUtil.executeBatches (GcsUtil.java:602)
at org.apache.beam.sdk.util.GcsUtil.getObjects (GcsUtil.java:341)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.matchNonGlobs (GcsFileSystem.java:216)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.match (GcsFileSystem.java:85)
at org.apache.beam.sdk.io.FileSystems.match (FileSystems.java:123)
at org.apache.beam.sdk.io.FileSystems.matchSingleFileSpec (FileSystems.java:188)
at org.apache.beam.runners.dataflow.util.PackageUtil.alreadyStaged (PackageUtil.java:159)
at org.apache.beam.runners.dataflow.util.PackageUtil.stagePackageSynchronously (PackageUtil.java:183)
at org.apache.beam.runners.dataflow.util.PackageUtil.lambda$stagePackage (PackageUtil.java:173)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly (TrustedListenableFutureTask.java:111)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.InterruptibleTask.run (InterruptibleTask.java:58)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask.run (TrustedListenableFutureTask.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
Caused by: com.google.api.client.http.HttpResponseException: 404 Not Found
Not Found
at com.google.api.client.http.HttpRequest.execute (HttpRequest.java:1070)
at com.google.api.client.googleapis.batch.BatchRequest.execute (BatchRequest.java:241)
at org.apache.beam.sdk.util.GcsUtil.lambda$executeBatches[=12=] (GcsUtil.java:596)
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly (TrustedListenableFutureTask.java:111)
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.InterruptibleTask.run (InterruptibleTask.java:58)
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask.run (TrustedListenableFutureTask.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
Mar 12, 2018 7:40:22 AM org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.AggregateFuture$RunningState handleException
SEVERE: Got more than one input Future failure. Logging failures after the first
java.io.IOException: Error executing batch GCS request
at org.apache.beam.sdk.util.GcsUtil.executeBatches(GcsUtil.java:610)
at org.apache.beam.sdk.util.GcsUtil.getObjects(GcsUtil.java:341)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.matchNonGlobs(GcsFileSystem.java:216)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.match(GcsFileSystem.java:85)
at org.apache.beam.sdk.io.FileSystems.match(FileSystems.java:123)
at org.apache.beam.sdk.io.FileSystems.matchSingleFileSpec(FileSystems.java:188)
at org.apache.beam.runners.dataflow.util.PackageUtil.alreadyStaged(PackageUtil.java:159)
at org.apache.beam.runners.dataflow.util.PackageUtil.stagePackageSynchronously(PackageUtil.java:183)
at org.apache.beam.runners.dataflow.util.PackageUtil.lambda$stagePackage(PackageUtil.java:173)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:111)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:58)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
看看这个 Stack Overflow post:Error using SpannerIO in apache beam. It's possibily related or the same issue described in the JIRA issue BEAM-2837。
Stack Overflow post 没有可接受的答案,但我能够通过明确定义所需的 com.google.api.grpc
依赖项并从 org.apache.beam
中排除版本来解决问题.
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
<version>0.1.9</version>
</dependency>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-io-google-cloud-platform</artifactId>
<version>${beam.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
</exclusion>
</exclusions>
</dependency>
如果您使用的是 gradle,请使用以下代码片段强制实施该版本。这解决了我的问题。
compile (group: 'com.google.api-client', name: 'google-api-client', version: '1.22.0') {
force = true
}
我正在尝试写一些来自 google pub/sub 的消息给 spanner。写入 bigtable 有效,因此在基础层面上没有遗漏任何内容。
我已经升级到 google-cloud-dataflow-java-sdk-all
v2.3.0,其中包括 SpannerIO 接收器。
我基本上是按照 API docs of SpannerIO.
的例子写的但是,我遇到了异常 internal_static_google_rpc_LocalizedMessage_fieldAccessorTable
完整堆栈跟踪:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project second-dataflow: An exception occured while executing the Java class. internal_static_google_rpc_LocalizedMessage_fieldAccessorTable
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. internal_static_google_rpc_LocalizedMessage_fieldAccessorTable
at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:339)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.lang.NoSuchFieldError: internal_static_google_rpc_LocalizedMessage_fieldAccessorTable
at com.google.rpc.LocalizedMessage.internalGetFieldAccessorTable (LocalizedMessage.java:87)
at com.google.protobuf.GeneratedMessageV3.getDescriptorForType (GeneratedMessageV3.java:121)
at io.grpc.protobuf.ProtoUtils.keyForProto (ProtoUtils.java:126)
at com.google.cloud.spanner.spi.v1.SpannerErrorInterceptor.<clinit> (SpannerErrorInterceptor.java:47)
at com.google.cloud.spanner.spi.v1.GrpcSpannerRpc.<init> (GrpcSpannerRpc.java:128)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerRpcFactory.create (SpannerOptions.java:70)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerRpcFactory.create (SpannerOptions.java:65)
at com.google.cloud.ServiceOptions.getRpc (ServiceOptions.java:443)
at com.google.cloud.spanner.SpannerOptions.getSpannerRpcV1 (SpannerOptions.java:315)
at com.google.cloud.spanner.SpannerImpl.<init> (SpannerImpl.java:138)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerFactory.create (SpannerOptions.java:60)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerFactory.create (SpannerOptions.java:55)
at com.google.cloud.ServiceOptions.getService (ServiceOptions.java:430)
at org.apache.beam.sdk.io.gcp.spanner.SpannerConfig.connectToSpanner (SpannerConfig.java:155)
at com.crypto20.DeveloperSubscription.main (DeveloperSubscription.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:748)
指定 withProjectId()
并不能解决问题。
也没有升级所有依赖项,包括传递引入的依赖项 - 除非我犯了一个错误(我不习惯数据流的内部结构以及每个依赖项的作用)。更新依赖项后,甚至无法暂存已编译的项目。
我怀疑有一个特定的依赖项需要更新,我尝试了各种组合,但无济于事。
更新:
我尝试过的其中一件事是将 grpc-google-common-protos
固定到 0.1.9
甚至是最新的 1.2.0
.
如果我这样做,甚至无法上传管道,因为我在上传前遇到以下异常:
Mar 12, 2018 7:40:22 AM org.apache.beam.runners.dataflow.util.PackageUtil stageClasspathElements
INFO: Uploading 120 files from PipelineOptions.filesToStage to staging location to prepare for execution.
[WARNING]
java.lang.RuntimeException: Error while staging packages
at org.apache.beam.runners.dataflow.util.PackageUtil.stageClasspathElements (PackageUtil.java:396)
at org.apache.beam.runners.dataflow.util.PackageUtil.stageClasspathElements (PackageUtil.java:272)
at org.apache.beam.runners.dataflow.util.GcsStager.stageFiles (GcsStager.java:76)
at org.apache.beam.runners.dataflow.util.GcsStager.stageDefaultFiles (GcsStager.java:64)
at org.apache.beam.runners.dataflow.DataflowRunner.run (DataflowRunner.java:661)
at org.apache.beam.runners.dataflow.DataflowRunner.run (DataflowRunner.java:174)
at org.apache.beam.sdk.Pipeline.run (Pipeline.java:311)
at org.apache.beam.sdk.Pipeline.run (Pipeline.java:297)
at com.crypto20.DeveloperSubscription.main (DeveloperSubscription.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:748)
Caused by: java.io.IOException: Error executing batch GCS request
at org.apache.beam.sdk.util.GcsUtil.executeBatches (GcsUtil.java:610)
at org.apache.beam.sdk.util.GcsUtil.getObjects (GcsUtil.java:341)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.matchNonGlobs (GcsFileSystem.java:216)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.match (GcsFileSystem.java:85)
at org.apache.beam.sdk.io.FileSystems.match (FileSystems.java:123)
at org.apache.beam.sdk.io.FileSystems.matchSingleFileSpec (FileSystems.java:188)
at org.apache.beam.runners.dataflow.util.PackageUtil.alreadyStaged (PackageUtil.java:159)
at org.apache.beam.runners.dataflow.util.PackageUtil.stagePackageSynchronously (PackageUtil.java:183)
at org.apache.beam.runners.dataflow.util.PackageUtil.lambda$stagePackage (PackageUtil.java:173)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly (TrustedListenableFutureTask.java:111)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.InterruptibleTask.run (InterruptibleTask.java:58)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask.run (TrustedListenableFutureTask.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: com.google.api.client.http.HttpResponseException: 404 Not Found
Not Found
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.AbstractFuture.getDoneValue (AbstractFuture.java:500)
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.AbstractFuture.get (AbstractFuture.java:479)
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get (AbstractFuture.java:76)
at org.apache.beam.sdk.util.GcsUtil.executeBatches (GcsUtil.java:602)
at org.apache.beam.sdk.util.GcsUtil.getObjects (GcsUtil.java:341)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.matchNonGlobs (GcsFileSystem.java:216)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.match (GcsFileSystem.java:85)
at org.apache.beam.sdk.io.FileSystems.match (FileSystems.java:123)
at org.apache.beam.sdk.io.FileSystems.matchSingleFileSpec (FileSystems.java:188)
at org.apache.beam.runners.dataflow.util.PackageUtil.alreadyStaged (PackageUtil.java:159)
at org.apache.beam.runners.dataflow.util.PackageUtil.stagePackageSynchronously (PackageUtil.java:183)
at org.apache.beam.runners.dataflow.util.PackageUtil.lambda$stagePackage (PackageUtil.java:173)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly (TrustedListenableFutureTask.java:111)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.InterruptibleTask.run (InterruptibleTask.java:58)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask.run (TrustedListenableFutureTask.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
Caused by: com.google.api.client.http.HttpResponseException: 404 Not Found
Not Found
at com.google.api.client.http.HttpRequest.execute (HttpRequest.java:1070)
at com.google.api.client.googleapis.batch.BatchRequest.execute (BatchRequest.java:241)
at org.apache.beam.sdk.util.GcsUtil.lambda$executeBatches[=12=] (GcsUtil.java:596)
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly (TrustedListenableFutureTask.java:111)
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.InterruptibleTask.run (InterruptibleTask.java:58)
at org.apache.beam.sdks.java.extensions.google.cloud.platform.core.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask.run (TrustedListenableFutureTask.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
Mar 12, 2018 7:40:22 AM org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.AggregateFuture$RunningState handleException
SEVERE: Got more than one input Future failure. Logging failures after the first
java.io.IOException: Error executing batch GCS request
at org.apache.beam.sdk.util.GcsUtil.executeBatches(GcsUtil.java:610)
at org.apache.beam.sdk.util.GcsUtil.getObjects(GcsUtil.java:341)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.matchNonGlobs(GcsFileSystem.java:216)
at org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem.match(GcsFileSystem.java:85)
at org.apache.beam.sdk.io.FileSystems.match(FileSystems.java:123)
at org.apache.beam.sdk.io.FileSystems.matchSingleFileSpec(FileSystems.java:188)
at org.apache.beam.runners.dataflow.util.PackageUtil.alreadyStaged(PackageUtil.java:159)
at org.apache.beam.runners.dataflow.util.PackageUtil.stagePackageSynchronously(PackageUtil.java:183)
at org.apache.beam.runners.dataflow.util.PackageUtil.lambda$stagePackage(PackageUtil.java:173)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:111)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:58)
at org.apache.beam.runners.dataflow.repackaged.com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
看看这个 Stack Overflow post:Error using SpannerIO in apache beam. It's possibily related or the same issue described in the JIRA issue BEAM-2837。
Stack Overflow post 没有可接受的答案,但我能够通过明确定义所需的 com.google.api.grpc
依赖项并从 org.apache.beam
中排除版本来解决问题.
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
<version>0.1.9</version>
</dependency>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-io-google-cloud-platform</artifactId>
<version>${beam.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
</exclusion>
</exclusions>
</dependency>
如果您使用的是 gradle,请使用以下代码片段强制实施该版本。这解决了我的问题。
compile (group: 'com.google.api-client', name: 'google-api-client', version: '1.22.0') {
force = true
}