googleads / googleads-java-lib

Google Ad Manager SOAP API Client Library for Java
Apache License 2.0
226 stars 361 forks source link

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkNotNull #169

Closed sivakandhan closed 5 years ago

sivakandhan commented 5 years ago

Hi Team,

In our project we have a requirement, to get our Banner stats report in daily basis.

so we have planned to make a web project, by hitting one URL we have to download our stats report in our APP server

for that i have downloaded the current version(V201811) of dfp java code

we are using the RunReportWithCustomFields class for our requirement, here if i run this class as a stand alone java application iit is working

when we access the the same class as a web project it is showing the below error for the first time.

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkNotNull(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; at com.google.api.ads.common.lib.auth.OfflineCredentials$Api.(OfflineCredentials.java:89) at com.google.api.ads.common.lib.auth.OfflineCredentials$Api.(OfflineCredentials.java:81) at admanager.axis.v201811.reportservice.RunReportWithCustomFields.accessDfp(RunReportWithCustomFields.java:160) at controller.DfpAxisController.getDfpStats(DfpAxisController.java:22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) Truncated. see log file for complete stacktrace

if we run the same again its showing the below error

java.lang.NoClassDefFoundError: Could not initialize class com.google.api.ads.common.lib.auth.OfflineCredentials$Api at admanager.axis.v201811.reportservice.RunReportWithCustomFields.accessDfp(RunReportWithCustomFields.java:160) at controller.DfpAxisController.getDfpStats(DfpAxisController.java:22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) Truncated. see log file for complete stacktrace

Note: when we access the class through our controller class its coming in to the RunReportWithCustomFields class, and the error accur at the below line

Credential oAuth2Credential = new OfflineCredentials.Builder().forApi(Api.AD_MANAGER).fromFile().build().generateCredential();

please do the needful, Thanks in advance.

kish0ree commented 5 years ago

The above error is being thrown even when using the newest release of java google Adwords library 4.4.0. Can someone update about the root cause of this issue any soon?

christopherseeley commented 5 years ago

This looks similar to issue #151.

What version of Guava is on your classpath? Can you share the output of mvn dependency:tree?

kish0ree commented 5 years ago

I'm using Guava 19.0, This is my mvn dependency.

com.google.api-ads ads-lib 4.1.0 com.google.api-ads adwords-axis 4.1.0 com.google.http-client google-http-client-jackson2 1.22.0
kish0ree commented 5 years ago

@christopherseeley please find the dependency tree ├─ com.google.api-ads:ads-lib:4.1.0 │ ├─ com.beust:jcommander:1.48 │ ├─ com.google.api-client:google-api-client:1.23.0 │ │ ├─ com.google.http-client:google-http-client-jackson2:1.23.0 │ │ │ ├─ com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.8.5 (possible incompatibility) │ │ │ └─ com.google.http-client:google-http-client:1.23.0 │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ │ ├─ commons-codec:commons-codec:1.10 │ │ │ ├─ commons-logging:commons-logging:1.2 │ │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ │ ├─ com.google.oauth-client:google-oauth-client:1.23.0 │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ └─ com.google.http-client:google-http-client:1.23.0 │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ │ ├─ commons-codec:commons-codec:1.10 │ │ │ ├─ commons-logging:commons-logging:1.2 │ │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ │ └─ com.google.guava:guava-jdk5:17.0 (excluded, this version present anyway) │ ├─ com.google.guava:guava:20.0 -> 19.0 (possible incompatibility) │ ├─ com.google.http-client:google-http-client-jackson2:1.23.0 │ │ ├─ com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.8.5 (possible incompatibility) │ │ └─ com.google.http-client:google-http-client:1.23.0 │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ ├─ commons-codec:commons-codec:1.10 │ │ ├─ commons-logging:commons-logging:1.2 │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ ├─ com.google.inject:guice:4.0 │ │ ├─ aopalliance:aopalliance:1.0 │ │ ├─ com.google.guava:guava:16.0.1 -> 19.0 (possible incompatibility) │ │ └─ javax.inject:javax.inject:1 │ ├─ com.google.inject.extensions:guice-assistedinject:4.0 │ │ └─ com.google.inject:guice:4.0 │ │ ├─ aopalliance:aopalliance:1.0 │ │ ├─ com.google.guava:guava:16.0.1 -> 19.0 (possible incompatibility) │ │ └─ javax.inject:javax.inject:1 │ ├─ com.google.inject.extensions:guice-multibindings:4.0 │ │ └─ com.google.inject:guice:4.0 │ │ ├─ aopalliance:aopalliance:1.0 │ │ ├─ com.google.guava:guava:16.0.1 -> 19.0 (possible incompatibility) │ │ └─ javax.inject:javax.inject:1 │ ├─ commons-beanutils:commons-beanutils:1.9.2 │ │ ├─ commons-logging:commons-logging:1.1.1 -> 1.2 (possible incompatibility) │ │ └─ commons-collections:commons-collections:3.2.1 (excluded, version 3.2.2 present anyway) │ ├─ commons-collections:commons-collections:3.2.2 │ ├─ commons-configuration:commons-configuration:1.10 │ │ ├─ commons-lang:commons-lang:2.6 │ │ └─ commons-logging:commons-logging:1.1.1 -> 1.2 (possible incompatibility) │ ├─ commons-lang:commons-lang:2.6 │ ├─ joda-time:joda-time:2.8.2 -> 2.9.7 (possible incompatibility) │ ├─ net.sf.opencsv:opencsv:1.8 │ └─ org.slf4j:slf4j-api:1.7.7 -> 1.7.25 ├─ com.google.api-ads:adwords-axis:4.1.0 │ ├─ com.google.api-ads:ads-lib:4.1.0 │ │ ├─ com.beust:jcommander:1.48 │ │ ├─ com.google.api-client:google-api-client:1.23.0 │ │ │ ├─ com.google.http-client:google-http-client-jackson2:1.23.0 │ │ │ │ ├─ com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.8.5 (possible incompatibility) │ │ │ │ └─ com.google.http-client:google-http-client:1.23.0 │ │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ │ │ ├─ commons-codec:commons-codec:1.10 │ │ │ │ ├─ commons-logging:commons-logging:1.2 │ │ │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ │ │ ├─ com.google.oauth-client:google-oauth-client:1.23.0 │ │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ │ └─ com.google.http-client:google-http-client:1.23.0 │ │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ │ │ ├─ commons-codec:commons-codec:1.10 │ │ │ │ ├─ commons-logging:commons-logging:1.2 │ │ │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ │ │ └─ com.google.guava:guava-jdk5:17.0 (excluded, this version present anyway) │ │ ├─ com.google.guava:guava:20.0 -> 19.0 (possible incompatibility) │ │ ├─ com.google.http-client:google-http-client-jackson2:1.23.0 │ │ │ ├─ com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.8.5 (possible incompatibility) │ │ │ └─ com.google.http-client:google-http-client:1.23.0 │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ │ ├─ commons-codec:commons-codec:1.10 │ │ │ ├─ commons-logging:commons-logging:1.2 │ │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ │ ├─ com.google.inject:guice:4.0 │ │ │ ├─ aopalliance:aopalliance:1.0 │ │ │ ├─ com.google.guava:guava:16.0.1 -> 19.0 (possible incompatibility) │ │ │ └─ javax.inject:javax.inject:1 │ │ ├─ com.google.inject.extensions:guice-assistedinject:4.0 │ │ │ └─ com.google.inject:guice:4.0 │ │ │ ├─ aopalliance:aopalliance:1.0 │ │ │ ├─ com.google.guava:guava:16.0.1 -> 19.0 (possible incompatibility) │ │ │ └─ javax.inject:javax.inject:1 │ │ ├─ com.google.inject.extensions:guice-multibindings:4.0 │ │ │ └─ com.google.inject:guice:4.0 │ │ │ ├─ aopalliance:aopalliance:1.0 │ │ │ ├─ com.google.guava:guava:16.0.1 -> 19.0 (possible incompatibility) │ │ │ └─ javax.inject:javax.inject:1 │ │ ├─ commons-beanutils:commons-beanutils:1.9.2 │ │ │ ├─ commons-logging:commons-logging:1.1.1 -> 1.2 (possible incompatibility) │ │ │ └─ commons-collections:commons-collections:3.2.1 (excluded, version 3.2.2 present anyway) │ │ ├─ commons-collections:commons-collections:3.2.2 │ │ ├─ commons-configuration:commons-configuration:1.10 │ │ │ ├─ commons-lang:commons-lang:2.6 │ │ │ └─ commons-logging:commons-logging:1.1.1 -> 1.2 (possible incompatibility) │ │ ├─ commons-lang:commons-lang:2.6 │ │ ├─ joda-time:joda-time:2.8.2 -> 2.9.7 (possible incompatibility) │ │ ├─ net.sf.opencsv:opencsv:1.8 │ │ └─ org.slf4j:slf4j-api:1.7.7 -> 1.7.25 │ └─ com.google.api-ads:ads-lib-axis:4.1.0 │ ├─ com.google.api-ads:ads-lib:4.1.0 │ │ ├─ com.beust:jcommander:1.48 │ │ ├─ com.google.api-client:google-api-client:1.23.0 │ │ │ ├─ com.google.http-client:google-http-client-jackson2:1.23.0 │ │ │ │ ├─ com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.8.5 (possible incompatibility) │ │ │ │ └─ com.google.http-client:google-http-client:1.23.0 │ │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ │ │ ├─ commons-codec:commons-codec:1.10 │ │ │ │ ├─ commons-logging:commons-logging:1.2 │ │ │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ │ │ ├─ com.google.oauth-client:google-oauth-client:1.23.0 │ │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ │ └─ com.google.http-client:google-http-client:1.23.0 │ │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ │ │ ├─ commons-codec:commons-codec:1.10 │ │ │ │ ├─ commons-logging:commons-logging:1.2 │ │ │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ │ │ └─ com.google.guava:guava-jdk5:17.0 (excluded, this version present anyway) │ │ ├─ com.google.guava:guava:20.0 -> 19.0 (possible incompatibility) │ │ ├─ com.google.http-client:google-http-client-jackson2:1.23.0 │ │ │ ├─ com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.8.5 (possible incompatibility) │ │ │ └─ com.google.http-client:google-http-client:1.23.0 │ │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ │ ├─ commons-codec:commons-codec:1.10 │ │ │ ├─ commons-logging:commons-logging:1.2 │ │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ │ ├─ com.google.inject:guice:4.0 │ │ │ ├─ aopalliance:aopalliance:1.0 │ │ │ ├─ com.google.guava:guava:16.0.1 -> 19.0 (possible incompatibility) │ │ │ └─ javax.inject:javax.inject:1 │ │ ├─ com.google.inject.extensions:guice-assistedinject:4.0 │ │ │ └─ com.google.inject:guice:4.0 │ │ │ ├─ aopalliance:aopalliance:1.0 │ │ │ ├─ com.google.guava:guava:16.0.1 -> 19.0 (possible incompatibility) │ │ │ └─ javax.inject:javax.inject:1 │ │ ├─ com.google.inject.extensions:guice-multibindings:4.0 │ │ │ └─ com.google.inject:guice:4.0 │ │ │ ├─ aopalliance:aopalliance:1.0 │ │ │ ├─ com.google.guava:guava:16.0.1 -> 19.0 (possible incompatibility) │ │ │ └─ javax.inject:javax.inject:1 │ │ ├─ commons-beanutils:commons-beanutils:1.9.2 │ │ │ ├─ commons-logging:commons-logging:1.1.1 -> 1.2 (possible incompatibility) │ │ │ └─ commons-collections:commons-collections:3.2.1 (excluded, version 3.2.2 present anyway) │ │ ├─ commons-collections:commons-collections:3.2.2 │ │ ├─ commons-configuration:commons-configuration:1.10 │ │ │ ├─ commons-lang:commons-lang:2.6 │ │ │ └─ commons-logging:commons-logging:1.1.1 -> 1.2 (possible incompatibility) │ │ ├─ commons-lang:commons-lang:2.6 │ │ ├─ joda-time:joda-time:2.8.2 -> 2.9.7 (possible incompatibility) │ │ ├─ net.sf.opencsv:opencsv:1.8 │ │ └─ org.slf4j:slf4j-api:1.7.7 -> 1.7.25 │ ├─ com.google.http-client:google-http-client:1.23.0 │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ ├─ commons-codec:commons-codec:1.10 │ │ ├─ commons-logging:commons-logging:1.2 │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ ├─ commons-discovery:commons-discovery:0.4 │ │ └─ commons-logging:commons-logging:1.0.4 -> 1.2 (possible incompatibility) │ ├─ javax.xml:jaxrpc-api:1.1 │ ├─ org.apache.axis:axis:1.4 │ └─ wsdl4j:wsdl4j:1.6.2 ├─ com.google.apis:google-api-services-tagmanager:v1-rev27-1.18.0-rc │ └─ com.google.api-client:google-api-client:1.18.0-rc -> 1.23.0 (possible incompatibility) │ ├─ com.google.guava:guava-jdk5:17.0 │ ├─ com.google.http-client:google-http-client-jackson2:1.23.0 │ │ ├─ com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.8.5 (possible incompatibility) │ │ └─ com.google.http-client:google-http-client:1.23.0 │ │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ │ ├─ commons-codec:commons-codec:1.10 │ │ ├─ commons-logging:commons-logging:1.2 │ │ └─ org.apache.httpcomponents:httpcore:4.4.9 │ └─ com.google.oauth-client:google-oauth-client:1.23.0 │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ └─ com.google.http-client:google-http-client:1.23.0 │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ ├─ commons-codec:commons-codec:1.10 │ ├─ commons-logging:commons-logging:1.2 │ └─ org.apache.httpcomponents:httpcore:4.4.9 ├─ com.google.http-client:google-http-client-jackson2:1.22.0 -> 1.23.0 (possible incompatibility) │ ├─ com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.8.5 (possible incompatibility) │ └─ com.google.http-client:google-http-client:1.23.0 │ ├─ com.google.code.findbugs:jsr305:1.3.9 -> 3.0.1 (possible incompatibility) │ └─ org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5 (possible incompatibility) │ ├─ commons-codec:commons-codec:1.10 │ ├─ commons-logging:commons-logging:1.2 │ └─ org.apache.httpcomponents:httpcore:4.4.9 ├─ com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20180219.1 │ └─ com.google.guava:guava:19.0

kish0ree commented 5 years ago

@christopherseeley please find the attachment if above comment is unclear. dep tree.txt

christopherseeley commented 5 years ago

Thanks! Looks like owasp-java-html-sanitizer has a conflicting guava dependency of 19.0, and this library requires 20.0.

Can you try upgrading it?

kish0ree commented 5 years ago

@christopherseeley I've excluded the guava 19.0 and put 20.0, even then the issue persists. Is there anything else that I should do?

tryandcatch commented 5 years ago

have the same issue when using 4.4.0 version Lib

tryandcatch commented 5 years ago

By using mvn dependency:tree command and search project dependencies related guava , found that springfox-swagger2 using guava 18.0, 2 ways:

christopherseeley commented 5 years ago

@kish0ree what version of guava does mvn dependency:tree show as being used after you made your changes?

kish0ree commented 5 years ago

@christopherseely! Found the issue, there was some library which was fetching. Guava-jdk 17 which doesn't have the required methods. So I've excluded that and included guava 27.1-jre. It's working now.

christopherseeley commented 5 years ago

Happy to hear it!