带有Google DatastoreIO的Apache Beam 2.1.0调用Guava Preconditions checkArgument对GAE中不存在的函数

时间:2017-09-20 20:00:51

标签: google-app-engine google-cloud-datastore google-cloud-dataflow apache-beam apache-beam-io

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

  

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

这发生在将生成数据存储区读取的行中。 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是一个很好的帮助。

1 个答案:

答案 0 :(得分:0)

如前所述,here对应Preconditions.checkArgument(boolean, String, int)Z是布尔值,Ljava/lang/String;是字符串,I是整数。这种方法should exist in Guava 20.0