googleads / google-ads-java

Google Ads API Client Library for Java
Apache License 2.0
171 stars 177 forks source link

Facing Exception NoSuchMethodError while Migrating Google Ads API version from v13 to v14 #736

Closed shagufta-codit closed 1 year ago

shagufta-codit commented 1 year ago

Describe the bug: While Upgrading the version for Google Ads API from v13 to v14, I am getting below Exception when trying to add budget for campaign creation.

Its failing while trying to make below call while sending request to create campaign

CampaignBudgetServiceClient campaignBudgetServiceClient = googleAdsClient.getLatestVersion().createCampaignBudgetServiceClient()

On further investigation we figured that its failing while executing this function GrpcOperationsStub, The client context its using is as below:

ClientContext{backgroundResources=[GrpcTransportChannel{managedChannel=com.google.api.gax.grpc.ChannelPool@663e4405}, com.google.api.gax.core.ExecutorAsBackgroundResource@40a30edc, com.google.api.gax.rpc.Watchdog@1a5589fc], executor=java.util.concurrent.ScheduledThreadPoolExecutor@ce1ef8f[Running, pool size = 1, active threads = 0, queued tasks = 1, completed tasks = 0], credentials=UserCredentials{requestMetadata=null, temporaryAccess=null, clientId=994750371900-uljdn20laj671ni2laj28cqmnjp26ouo.apps.googleusercontent.com, tokenServerUri=https://oauth2.googleapis.com/token, transportFactoryClassName=com.google.auth.oauth2.OAuth2Utils$DefaultHttpTransportFactory, quotaProjectId=null}, transportChannel=GrpcTransportChannel{managedChannel=com.google.api.gax.grpc.ChannelPool@663e4405}, headers={}, internalHeaders={x-goog-api-client=gl-java/1.8.0_382 gapic/26.0.0 gax/2.29.0 grpc/1.55.1}, clock=com.google.api.core.NanoClock@186b8c7a, defaultCallContext=com.google.api.gax.grpc.GrpcCallContext@9a9cd06d, streamWatchdog=com.google.api.gax.rpc.Watchdog@1a5589fc, streamWatchdogCheckInterval=PT10S, endpoint=googleads.googleapis.com:443, quotaProjectId=null, tracerFactory=com.google.api.gax.tracing.BaseApiTracerFactory@75d4cb0d}

Steps to Reproduce:

Exception: java.lang.reflect.InvocationTargetException [java.lang.NoSuchMethodError: com.google.api.client.util.escape.PercentEscaper.(Ljava/lang/String;)V]

Expected behavior:

The request should have went through and created a campaign for the same

Client library version and API version: Client library version: java 8 Google Ads API version: V14 JDK version: 1.8

Request/Response Logs:

Anything else we should know about your project / environment:

jradcliff commented 1 year ago

Hi,

Could you let me know which release of the library you are using?

https://github.com/googleads/google-ads-java/releases

Also, please share how you are declaring your dependencies. It may also be useful to share the output from mvn dependency:tree (if using Maven) or ./gradlew dependencies (if using Gradle). This looks like a dependency issue to me.

Thanks, Josh, Google Ads API Team

shagufta-codit commented 1 year ago

Hi Josh,

I am using this library: Google Ads API Client Library for Java - v26.0.0

Maven dependency I am using is:

     <dependency>
com.google.api-ads google-ads

https://bitbucket.org/tapeng/tapclicks/branch/GA-TO-6417-Migrationv14#Lmicroservices/TapOrdersIntegrations/pom.xmlF74T74

26.0.0

Thanks, Shagufta

On Fri, Sep 22, 2023 at 7:12 PM Josh Radcliff @.***> wrote:

Hi,

Could you let me know which release of the library you are using?

https://github.com/googleads/google-ads-java/releases

Also, please share how you are declaring your dependencies. It may also be useful to share the output from mvn dependency:tree (if using Maven) or ./gradlew dependencies (if using Gradle). This looks like a dependency issue to me.

Thanks, Josh, Google Ads API Team

— Reply to this email directly, view it on GitHub https://github.com/googleads/google-ads-java/issues/736#issuecomment-1731443322, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATMD6OCIRX6SZKCQ2QYSI3LX3WIUVANCNFSM6AAAAAA5C4NA4M . You are receiving this because you authored the thread.Message ID: @.***>

jradcliff commented 1 year ago

Could you share the output from the following command?

mvn dependency:tree
shagufta-codit commented 1 year ago

[INFO] com.tapclicks.integrations:TapOrdersIntegrations:jar:0.1 [INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.5.7.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.5.7.RELEASE:compile [INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.7.RELEASE:compile [INFO] | | | +- ch.qos.logback:logback-classic:jar:1.1.11:compile [INFO] | | | | - ch.qos.logback:logback-core:jar:1.1.11:compile [INFO] | | | +- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile [INFO] | | | +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile [INFO] | | | - org.slf4j:log4j-over-slf4j:jar:1.7.25:compile [INFO] | | - org.yaml:snakeyaml:jar:1.17:runtime [INFO] | - org.springframework.boot:spring-boot-actuator:jar:1.5.7.RELEASE:compile [INFO] | - org.springframework:spring-context:jar:4.3.11.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.5.7.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.7.RELEASE:compile [INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.20:compile [INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.20:compile [INFO] | | - org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.20:compile [INFO] | +- org.hibernate:hibernate-validator:jar:5.3.5.Final:compile [INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile [INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile [INFO] | | - com.fasterxml:classmate:jar:1.3.4:compile [INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile [INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile [INFO] | | - com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile [INFO] | +- org.springframework:spring-web:jar:4.3.11.RELEASE:compile [INFO] | | +- org.springframework:spring-aop:jar:4.3.11.RELEASE:compile [INFO] | | - org.springframework:spring-beans:jar:4.3.11.RELEASE:compile [INFO] | - org.springframework:spring-webmvc:jar:4.3.11.RELEASE:compile [INFO] | - org.springframework:spring-expression:jar:4.3.11.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-devtools:jar:1.5.7.RELEASE:runtime [INFO] | +- org.springframework.boot:spring-boot:jar:1.5.7.RELEASE:compile [INFO] | - org.springframework.boot:spring-boot-autoconfigure:jar:1.5.7.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.7.RELEASE:test [INFO] | +- org.springframework.boot:spring-boot-test:jar:1.5.7.RELEASE:test [INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.7.RELEASE:test [INFO] | +- com.jayway.jsonpath:json-path:jar:2.2.0:test [INFO] | | - net.minidev:json-smart:jar:2.2.1:test [INFO] | | - net.minidev:accessors-smart:jar:1.1:test [INFO] | | - org.ow2.asm:asm:jar:5.0.3:test [INFO] | +- junit:junit:jar:4.12:test [INFO] | +- org.assertj:assertj-core:jar:2.6.0:test [INFO] | +- org.mockito:mockito-core:jar:1.10.19:test [INFO] | | - org.objenesis:objenesis:jar:2.1:test [INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test [INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test [INFO] | +- org.skyscreamer:jsonassert:jar:1.4.0:test [INFO] | | - com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test [INFO] | +- org.springframework:spring-core:jar:4.3.11.RELEASE:compile [INFO] | - org.springframework:spring-test:jar:4.3.11.RELEASE:test [INFO] +- com.google.api-ads:ads-lib:jar:4.2.0:compile [INFO] | +- com.google.guava:guava:jar:20.0:compile [INFO] | +- com.google.inject:guice:jar:4.0:compile [INFO] | | +- javax.inject:javax.inject:jar:1:compile [INFO] | | - aopalliance:aopalliance:jar:1.0:compile [INFO] | +- com.google.inject.extensions:guice-assistedinject:jar:4.0:compile [INFO] | +- com.google.inject.extensions:guice-multibindings:jar:4.0:compile [INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile [INFO] | +- commons-configuration:commons-configuration:jar:1.10:compile [INFO] | | - commons-logging:commons-logging:jar:1.1.1:compile [INFO] | +- commons-collections:commons-collections:jar:3.2.2:compile [INFO] | +- commons-lang:commons-lang:jar:2.6:compile [INFO] | +- net.sf.opencsv:opencsv:jar:1.8:compile [INFO] | +- org.slf4j:slf4j-api:jar:1.7.25:compile [INFO] | +- joda-time:joda-time:jar:2.9.9:compile [INFO] | +- com.google.api-client:google-api-client:jar:1.23.0:compile [INFO] | | - com.google.oauth-client:google-oauth-client:jar:1.23.0:compile [INFO] | +- com.google.http-client:google-http-client-jackson2:jar:1.23.0:compile [INFO] | | - com.google.http-client:google-http-client:jar:1.23.0:compile [INFO] | | - org.apache.httpcomponents:httpclient:jar:4.5.3:compile [INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.6:compile [INFO] | | - commons-codec:commons-codec:jar:1.10:compile [INFO] | - com.beust:jcommander:jar:1.48:compile [INFO] +- com.google.api-ads:adwords-axis:jar:4.2.0:compile [INFO] | - com.google.api-ads:ads-lib-axis:jar:4.2.0:compile [INFO] | +- commons-discovery:commons-discovery:jar:0.4:compile [INFO] | +- javax.xml:jaxrpc-api:jar:1.1:compile [INFO] | +- org.apache.axis:axis:jar:1.4:compile [INFO] | - wsdl4j:wsdl4j:jar:1.6.3:compile [INFO] +- com.google.apis:google-api-services-content:jar:v2-rev22-1.19.0:compile [INFO] +- com.google.oauth-client:google-oauth-client-jetty:jar:1.30.4:compile [INFO] | +- com.google.oauth-client:google-oauth-client-java6:jar:1.30.4:compile [INFO] | - org.eclipse.jetty:jetty-server:jar:9.4.6.v20170531:compile [INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile [INFO] | +- org.eclipse.jetty:jetty-http:jar:9.4.6.v20170531:compile [INFO] | | - org.eclipse.jetty:jetty-util:jar:9.4.6.v20170531:compile [INFO] | - org.eclipse.jetty:jetty-io:jar:9.4.6.v20170531:compile [INFO] +- org.glassfish:javax.json:jar:1.0.4:compile [INFO] +- com.google.api-ads:google-ads:jar:26.0.0:compile [INFO] | +- com.google.api:gax:jar:2.29.0:compile [INFO] | | +- com.google.api:api-common:jar:2.12.0:compile [INFO] | | +- com.google.api.grpc:proto-google-common-protos:jar:2.20.0:compile [INFO] | | +- org.threeten:threetenbp:jar:1.6.8:compile [INFO] | | - io.opencensus:opencensus-api:jar:0.31.1:compile [INFO] | | - io.grpc:grpc-context:jar:1.27.2:compile [INFO] | +- com.google.api:gax-grpc:jar:2.29.0:compile [INFO] | | +- io.grpc:grpc-api:jar:1.55.1:compile [INFO] | | +- io.grpc:grpc-alts:jar:1.55.1:compile [INFO] | | | +- io.grpc:grpc-grpclb:jar:1.55.1:compile [INFO] | | | - org.conscrypt:conscrypt-openjdk-uber:jar:2.5.2:compile [INFO] | | +- io.grpc:grpc-auth:jar:1.55.1:compile [INFO] | | +- io.grpc:grpc-netty-shaded:jar:1.55.1:compile [INFO] | | | +- io.perfmark:perfmark-api:jar:0.25.0:runtime [INFO] | | | - io.grpc:grpc-core:jar:1.55.1:compile (version selected from constraint [1.55.1,1.55.1]) [INFO] | | | +- com.google.android:annotations:jar:4.1.1.4:runtime [INFO] | | | - org.codehaus.mojo:animal-sniffer-annotations:jar:1.21:runtime [INFO] | | - io.grpc:grpc-googleapis:jar:1.55.1:runtime [INFO] | | - io.grpc:grpc-xds:jar:1.55.1:runtime (version selected from constraint [1.55.1,1.55.1]) [INFO] | | +- io.opencensus:opencensus-proto:jar:0.2.0:runtime [INFO] | | +- io.grpc:grpc-services:jar:1.55.1:runtime [INFO] | | - com.google.re2j:re2j:jar:1.6:runtime [INFO] | +- com.google.protobuf:protobuf-java:jar:3.23.2:compile [INFO] | +- io.grpc:grpc-stub:jar:1.55.1:compile [INFO] | | - com.google.errorprone:error_prone_annotations:jar:2.18.0:compile [INFO] | +- io.grpc:grpc-protobuf:jar:1.55.1:compile [INFO] | | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile [INFO] | | - io.grpc:grpc-protobuf-lite:jar:1.55.1:compile [INFO] | +- com.google.auth:google-auth-library-oauth2-http:jar:1.17.0:compile [INFO] | | - com.google.http-client:google-http-client-gson:jar:1.42.3:compile [INFO] | +- com.google.auth:google-auth-library-credentials:jar:1.17.0:compile [INFO] | +- com.google.api-ads:google-ads-codegen:jar:26.0.0:compile [INFO] | | +- com.google.api-ads:google-ads-stubs-lib:jar:26.0.0:compile [INFO] | | +- com.google.api-ads:google-ads-stubs-v12:jar:26.0.0:compile [INFO] | | +- com.google.api-ads:google-ads-stubs-v13:jar:26.0.0:compile [INFO] | | +- com.google.api-ads:google-ads-stubs-v14:jar:26.0.0:compile [INFO] | | - com.squareup:javapoet:jar:1.11.1:runtime [INFO] | +- com.google.protobuf:protobuf-java-util:jar:3.23.2:runtime [INFO] | | +- com.google.code.gson:gson:jar:2.8.1:compile [INFO] | | - com.google.j2objc:j2objc-annotations:jar:1.3:runtime [INFO] | +- com.google.auto.service:auto-service:jar:1.0.1:runtime [INFO] | | +- com.google.auto.service:auto-service-annotations:jar:1.0.1:runtime [INFO] | | - com.google.auto:auto-common:jar:1.2:runtime [INFO] | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile [INFO] | - com.google.auto.value:auto-value-annotations:jar:1.10.1:compile [INFO] - com.opencsv:opencsv:jar:4.1:compile [INFO] +- org.apache.commons:commons-lang3:jar:3.6:compile [INFO] - org.apache.commons:commons-text:jar:1.1:compile [INFO]

[INFO] BUILD SUCCESS [INFO]

[INFO] Total time: 8.601 s [INFO] Finished at: 2023-09-22T19:28:48+05:30 [INFO]

On Fri, Sep 22, 2023 at 7:25 PM Josh Radcliff @.***> wrote:

Could you share the output from the following command?

mvn dependency:tree

— Reply to this email directly, view it on GitHub https://github.com/googleads/google-ads-java/issues/736#issuecomment-1731464837, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATMD6OH2XQPY5YMW3TAWYKDX3WKDPANCNFSM6AAAAAA5C4NA4M . You are receiving this because you authored the thread.Message ID: @.***>

jradcliff commented 1 year ago

I see you have dependencies on the following libraries for the old, sunset AdWords API:

Since that API is completely shut down, you shouldn't need those anymore, and those dependencies are pulling in outdated versions of some libraries such as com.google.http-client:google-http-client:1.23.0. That's what is leading to the error you're seeing.

Please remove those two dependencies and let me know if you still encounter issues.

Thanks, Josh

jradcliff commented 1 year ago

I'm closing this issue since removing the old AdWords API dependencies from your project should fix it. If you still encounter issues after making that change, feel free to reopen this issue.

Thanks, Josh, Google Ads API Team

jradcliff commented 1 year ago

@shagufta-codit I just received an alert because your first post on this issue included your refreshToken. Please do the following:

  1. Rotate the secret if it's in use to prevent breaking workflows.
  2. Revoke this Google OAuth Refresh Token through Google to prevent unauthorized access. Learn more about Google tokens at https://developers.google.com/identity/protocols/oauth2#expiration.
  3. Check security logs for potential breaches.

Thank you