0

在构建应从数据存储区读取的数据流模板时,我在堆栈驱动程序日志中收到以下错误(来自 Google App Engine):

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V at org.apache.beam.sdk.io.gcp.datastore.DatastoreV1$Read.withQuery(DatastoreV1. java:494) .... 我的代码

这发生在将从 Datastore 生成读取的行中。pom 依赖

<!-- https://mvnrepository.com/artifact/org.apache.beam/beam-sdks-java-io-google-cloud-platform -->
<dependency>
    <groupId>org.apache.beam</groupId>
    <artifactId>beam-sdks-java-io-google-cloud-platform</artifactId>
    <version>2.1.0</version>
</dependency>

参考

<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>20.0</version>
</dependency>

但是这个版本在类 Preconditions 中不包含方法 checkArgument(String string),我看过的任何其他版本也没有。如上所述,模板应该是在GAE柔性环境项目中构建并稍后执行,但是模板生成失败。

如果我让 main 函数在本地生成模板,它可以正常工作,但是一旦项目在 GAE 中,它就会失败。

任何输入都受到高度赞赏

编辑:com.google.guava 的依赖树:

[INFO] xy.company_name.test:bcc.dataflow.project_name:war:0.0.3
[INFO] \- org.apache.beam:beam-runners-google-cloud-dataflow-java:jar:2.1.0:compile
[INFO]    +- org.apache.beam:beam-sdks-java-extensions-google-cloud-platform-core:jar:2.1.0:compile
[INFO]    |  \- com.google.cloud.bigdataoss:gcsio:jar:1.4.5:compile
[INFO]    |     \- (com.google.guava:guava:jar:18.0:compile - omitted for conflict with 20.0)
[INFO]    +- org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.1.0:compile
[INFO]    |  +- io.grpc:grpc-core:jar:1.2.0:compile
[INFO]    |  |  \- (com.google.guava:guava:jar:19.0:compile - omitted for conflict with 20.0)
[INFO]    |  +- com.google.api:gax-grpc:jar:0.20.0:compile
[INFO]    |  |  +- io.grpc:grpc-protobuf:jar:1.2.0:compile
[INFO]    |  |  |  +- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO]    |  |  |  \- io.grpc:grpc-protobuf-lite:jar:1.2.0:compile
[INFO]    |  |  |     \- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO]    |  |  +- com.google.api:api-common:jar:1.1.0:compile
[INFO]    |  |  |  \- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO]    |  |  +- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO]    |  |  \- com.google.api:gax:jar:1.3.1:compile
[INFO]    |  |     \- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO]    |  +- com.google.cloud:google-cloud-core-grpc:jar:1.2.0:compile
[INFO]    |  |  +- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO]    |  |  \- com.google.protobuf:protobuf-java-util:jar:3.2.0:compile
[INFO]    |  |     \- (com.google.guava:guava:jar:18.0:compile - omitted for conflict with 19.0)
[INFO]    |  +- com.google.cloud.datastore:datastore-v1-proto-client:jar:1.4.0:compile
[INFO]    |  |  \- (com.google.guava:guava:jar:18.0:compile - omitted for conflict with 19.0)
[INFO]    |  +- io.grpc:grpc-all:jar:1.2.0:runtime
[INFO]    |  |  \- io.grpc:grpc-protobuf-nano:jar:1.2.0:runtime
[INFO]    |  |     \- (com.google.guava:guava:jar:19.0:runtime - omitted for duplicate)
[INFO]    |  +- com.google.cloud:google-cloud-core:jar:1.0.2:compile
[INFO]    |  |  \- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO]    |  +- com.google.cloud.bigtable:bigtable-protos:jar:0.9.7.1:compile
[INFO]    |  |  \- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO]    |  +- com.google.cloud.bigtable:bigtable-client-core:jar:0.9.7.1:compile
[INFO]    |  |  +- com.google.auth:google-auth-library-appengine:jar:0.6.1:compile
[INFO]    |  |  |  \- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO]    |  |  \- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO]    |  \- com.google.guava:guava:jar:20.0:compile
[INFO]    +- com.google.auth:google-auth-library-oauth2-http:jar:0.7.1:compile
[INFO]    |  \- (com.google.guava:guava:jar:19.0:compile - omitted for conflict with 20.0)
[INFO]    \- com.google.cloud.bigdataoss:util:jar:1.4.5:compile
[INFO]       \- (com.google.guava:guava:jar:18.0:compile - omitted for conflict with 20.0)

更新:

添加后

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>20.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>

并更新处理 DatastoreEntities 的函数,它似乎又可以工作了!很抱歉打扰,有时它只是有助于解决问题,而 stackoverflow 对此很有帮助。

4

1 回答 1

0

如此处所述,对应于Preconditions.checkArgument(boolean, String, int). Z是布尔值,是Ljava/lang/String;字符串,I是整数。这个方法应该存在于 Guava 20.0中。

于 2017-09-20T20:58:45.457 回答