Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sivakandhan opened this issue Feb 8, 2019 · 12 comments
Assignees

Comments

@sivakandhan
Copy link

@sivakandhan sivakandhan commented Feb 8, 2019

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

This comment has been minimized.

Copy link

@kish0ree kish0ree commented Mar 13, 2019

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

This comment has been minimized.

Copy link
Member

@christopherseeley christopherseeley commented Mar 13, 2019

This looks similar to issue #151.

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

@kish0ree

This comment has been minimized.

Copy link

@kish0ree kish0ree commented Mar 13, 2019

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

This comment has been minimized.

Copy link

@kish0ree kish0ree commented Mar 13, 2019

@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

This comment has been minimized.

Copy link

@kish0ree kish0ree commented Mar 13, 2019

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

@christopherseeley

This comment has been minimized.

Copy link
Member

@christopherseeley christopherseeley commented Mar 14, 2019

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

This comment has been minimized.

Copy link

@kish0ree kish0ree commented Mar 14, 2019

@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

This comment has been minimized.

Copy link

@tryandcatch tryandcatch commented Mar 18, 2019

have the same issue when using 4.4.0 version Lib

@tryandcatch

This comment has been minimized.

Copy link

@tryandcatch tryandcatch commented Mar 18, 2019

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

  • exclusive guava from swagger2 and specific guava version
    pom.xml:
        <!--other code.....-->
        <!--swagger2-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.7.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--specific guava version-->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>22.0</version>
        </dependency>
        <!--other code.....-->
  • upgrade swagger version:
    pom.xml:
        <!--swagger2-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.8.0</version><!-- version >= 2.8.x works fine-->
        </dependency>
@christopherseeley

This comment has been minimized.

Copy link
Member

@christopherseeley christopherseeley commented Mar 22, 2019

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

@kish0ree

This comment has been minimized.

Copy link

@kish0ree kish0ree commented Mar 22, 2019

@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

This comment has been minimized.

Copy link
Member

@christopherseeley christopherseeley commented Mar 22, 2019

Happy to hear it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.