googleads / googleads-java-lib

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

Exception as java.lang.NoSuchMethodError #151

Closed Rakesh-Vishwanathula closed 6 years ago

Rakesh-Vishwanathula commented 6 years ago

Hi Guys, I'm trying to connect DFP API with Eclipse based application(Mulesoft) and getting following Exception. Root Exception stack trace: 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 com.dfp.util.RunAdExchangeReport.onCall(RunAdExchangeReport.java:63)

I don't understand what i'm missing in my pom set up. Here is the attachment of source code and pom. Archive.zip you please provide solution ASAP as it is critical project?? Thanks!

AlexanderDahmen commented 6 years ago

The com.google.api.ads.common.lib.auth.OfflineCredentials class (and nested Api class) are part of the ads-lib-3.16.0 jar file. Checking that class' bytecode, there is a call to com/google/common/base/Preconditions:checkNotNull(java/lang/Object; java/lang/String; java/lang/Object;) java/lang/Object - which matches the call made in the Source Code - so it is not the same error I had in issue #150 , where the bytecode contains an errornous call.

Looking at the guava-20.0.jar file, the method is definitely available:

public static <T extends Object> T checkNotNull(T t, @javax.annotation.Nullable String string, @javax.annotation.Nullable Object o) { ... }

Are you sure your Guava dependency is the correct version for your ads-lib depdendency? Maybe check your Maven Graph if there are any conflicts leading to wrong library versions being loaded.

nwbirnie commented 6 years ago

Hey,

As Alex points out, it's quite likely that you have the wrong version of Guava on the classpath. Could you post the output of mvn dependency:tree please?

Best wishes,

Nick

Rakesh-Vishwanathula commented 6 years ago

Hi Guys,

Here is the attachment of output of mvn dependency:tree. Looking forward for solution and please let me know if you need anything from my side. Thanks!

Regards, Rakesh

From: Nick Birnie notifications@github.com Reply-To: googleads/googleads-java-lib reply@reply.github.com Date: Tuesday, July 31, 2018 at 8:01 AM To: googleads/googleads-java-lib googleads-java-lib@noreply.github.com Cc: Rakesh Vishwanathula rvishwanathula@pandora.com, Author author@noreply.github.com Subject: Re: [googleads/googleads-java-lib] Exception as java.lang.NoSuchMethodError (#151)

Hey,

As Alex points out, it's quite likely that you have the wrong version of Guava on the classpath. Could you post the output of mvn dependency:tree please?

Best wishes,

Nick

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_googleads_googleads-2Djava-2Dlib_issues_151-23issuecomment-2D409251900&d=DwMCaQ&c=gFTBenQ7Vj71sUi1A4CkFnmPzqwDo07QsHw-JRepxyw&r=Ahd-3Tb6xUPqJEWGY7E-aQiegKdEuuNd8DHCQMECrTY&m=XYkJgBnt2-HGZQdoXcjQjoXb8ASZaFVhiUYDCCntFJY&s=X5uaNKGmmSTksbuw-d8ujumhJrumAO0PNDJ77Cl6El8&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_An9Ka3L8p7R9HpqOhQfzYvyy5g7-2Dqcvpks5uMHFFgaJpZM4VmCdS&d=DwMCaQ&c=gFTBenQ7Vj71sUi1A4CkFnmPzqwDo07QsHw-JRepxyw&r=Ahd-3Tb6xUPqJEWGY7E-aQiegKdEuuNd8DHCQMECrTY&m=XYkJgBnt2-HGZQdoXcjQjoXb8ASZaFVhiUYDCCntFJY&s=N0e18ayyaWE8ar1ZNJfpymvv8p8wvrwzB2_1lPiXBFw&e=.

nwbirnie commented 6 years ago

Thanks Rakesh, unfortunately the email reply dropped the attachment. Would you kindly attach on the Github UI please?

Best wishes,

Nick

Rakesh-Vishwanathula commented 6 years ago

maven.zip Here is the attachment. Thanks!

nwbirnie commented 6 years ago

The reason for this is that you have a direct dependency on Guava 23.6-jre. However, ads-lib and adwords-axis require Guava 20.0. Can you downgrade the dependency perhaps?

Rakesh-Vishwanathula commented 6 years ago

Tried with guava 20.0 but still getting same error.

Rakesh-Vishwanathula commented 6 years ago

We are using ads-lib and dfp-axis but not adwords-axis. Will that make any difference with guava??

nwbirnie commented 6 years ago

Tried with guava 20.0 but still getting same error.

Could you post the full error trace, output of mvn dependency:tree -X when using Guava 20.0 please?

We are using ads-lib and dfp-axis but not adwords-axis. Will that make any difference with guava??

That's fine, there should be no difference, since the Guava dependency comes from ads-lib rather than the axis packages.

Rakesh-Vishwanathula commented 6 years ago

Here is the attachment of Java class, pom, Error with full stack trace, mvn dependency:tree. I'm using dfp-axis version=v201805 Archive 2.zip

Rakesh-Vishwanathula commented 6 years ago

maven-X.zip Here is the full mvn dependency:tree -X

nwbirnie commented 6 years ago

I was digging into this and came across this document about classloaders in Mule. In short, Mule has a special classloader for its runtime which is likely to include Guava 18.0, you could verify this by checking the application folder for the offending jar. Since Java will by default try the parent classloader before loading a new class (details) your application's dependency on Guava 20.0 is likely being ignored.

So there's a couple of options here in terms of a workaround.

  1. rebuild the client libraries from source, swapping out the Guava 20.0 dependency with 18.0 and fixing the compiler errors (I just tried this and there's only two lines which need to be changed.)
  2. swap out the mule installed Guava jar with 20.0 and check if Mule still runs

Would you be able to try one of these out and see if it solves your issue?

Also, just in passing, is this a brand new application or was this working with a previous version of the client libs?

Rakesh-Vishwanathula commented 6 years ago

Finally it's working. Thanks!