2

After updating code to use the latest version of the google-cloud-storage and google-cloud-bigquery libraries (version 1.25.0) we are now throwing a NoSuchMethodError.

Exception in thread "main" java.lang.NoSuchMethodError: com.google.api.services.bigquery.model.JobReference.setLocation(Ljava/lang/String;)Lcom/google/api/services/bigquery/model/JobReference;

After doing some research it appears that is a dependency issue with the guava library. However, following the advice posted elsewhere (overriding the guava dependency) has not solved the issue, trying several guava versions.

Looking at the dependency tree it seems to me that the only place that the guava dependency appears is in the google-cloud libraries. Sometimes it requires version 20.0 and others 19.0. I've attached an excerpt of the tree that lead me to that conclusion.

├─ com.google.cloud:google-cloud-bigquery:1.25.0
│  ├─ com.google.auto.value:auto-value:1.4
│  ├─ com.google.cloud:google-cloud-core:1.25.0
│  │  ├─ com.google.api:api-common:1.5.0
│  │  │  ├─ com.google.code.findbugs:jsr305:3.0.0 -> 3.0.1
│  │  │  └─ com.google.guava:guava:19.0 -> 20.0
│  │  ├─ com.google.api:gax:1.23.0
│  │  │  ├─ com.google.api:api-common:1.5.0
│  │  │  │  ├─ com.google.code.findbugs:jsr305:3.0.0 -> 3.0.1
│  │  │  │  └─ com.google.guava:guava:19.0 -> 20.0
│  │  │  ├─ com.google.auth:google-auth-library-oauth2-http:0.9.0
│  │  │  │  ├─ com.google.auth:google-auth-library-credentials:0.9.0
│  │  │  │  ├─ com.google.guava:guava:19.0 -> 20.0
│  │  │  │  ├─ com.google.http-client:google-http-client:1.19.0 -> 1.23.0
│  │  │  │  │  ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1
│  │  │  │  │  └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.3.6
│  │  │  │  │     ├─ commons-codec:commons-codec:1.6 -> 1.10
│  │  │  │  │     ├─ commons-logging:commons-logging:1.1.3
│  │  │  │  │     └─ org.apache.httpcomponents:httpcore:4.3.3
│  │  │  │  └─ com.google.http-client:google-http-client-jackson2:1.19.0 -> 1.23.0
│  │  │  │     ├─ com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.9.4
│  │  │  │     └─ com.google.http-client:google-http-client:1.23.0
│  │  │  │        ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1
│  │  │  │        └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.3.6
│  │  │  │           ├─ commons-codec:commons-codec:1.6 -> 1.10
│  │  │  │           ├─ commons-logging:commons-logging:1.1.3
│  │  │  │           └─ org.apache.httpcomponents:httpcore:4.3.3
│  │  │  ├─ com.google.code.findbugs:jsr305:3.0.0 -> 3.0.1
│  │  │  ├─ com.google.guava:guava:20.0
│  │  │  └─ org.threeten:threetenbp:1.3.3

Could anyone offer any advice? I can't imagine we're the only ones to come across this issue.

jackt
  • 55
  • 7
  • 1
    I have found [this](https://stackoverflow.com/questions/35186/how-do-i-fix-a-nosuchmethoderror) that I think it might be useful. Quote: "Look at the stack trace ... If the exception appears when calling a method on an object in a library, you are most likely using separate versions of the library when compiling and running. Make sure you have the right version both places." – Xiaoxia Lin Apr 27 '18 at 13:52

1 Answers1

0

in my case the solution was removing some old dependency:

<dependency>
 <groupId>com.google.cloud</groupId>
 <artifactId>google-cloud-bigquery</artifactId>
 <version>0.11.0-beta</version>
</dependency>
rtbf
  • 1,509
  • 1
  • 16
  • 35