Big Query API Exception

问题描述 投票:0回答:1

我有这个问题

java.lang.NoSuchMethodError:com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava / util / concurrent / Executor;

[使用Google的Big Query API时。

我正在使用JSF,GlassFish 4.1。

有我的方法引发异常:

public void process() throws InterruptedException, FileNotFoundException, IOException {
   GoogleCredentials credentials;
    File credentialsPath = new File("/home/jesus_miranda/Downloads/credential2.json");  // TODO: update to your key path.
    try (FileInputStream serviceAccountStream = new FileInputStream(credentialsPath)) {
        credentials = ServiceAccountCredentials.fromStream(serviceAccountStream);
    }
    // Instantiate a client.
    BigQuery bigquery = BigQueryOptions.newBuilder().setCredentials(credentials).build().getService();
    String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;";
    QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query).build();

    for (FieldValueList row : bigquery.query(queryConfig).iterateAll()) {//At this line the program failed.
        for (FieldValue val : row) {
            System.out.printf("%s,", val.toString());
        }
        System.out.printf("\n");
    }
}

[请帮助我,我读了很多论坛,所有论坛都讨论了番石榴的版本。我更新并降级了番石榴版本,但仍然无法正常工作。

问候!

java guava
1个回答
0
投票
  1. 此问题似乎是版本不匹配的结果。查看BigQuery API的依赖项声明,看看使用了哪个Guava版本。

  2. 也许您正在构建应用程序,但忘了将番石榴的番石榴着色/添加到jar中。

© www.soinside.com 2019 - 2024. All rights reserved.