googleads / google-ads-java

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

Got Error SLF4J: Failed toString() invocation on an object of type [com.google.ads.googleads.v15.services.SearchGoogleAdsStreamRequest] #766

Closed tvc12 closed 6 months ago

tvc12 commented 8 months ago

Hi Google Ads team, I already opened a support case via the form at https://developers.google.com/google-ads/api/support with case ID ref:!00D1U01174p.!5004Q02rW1xH:ref. But the support representative directed me to open an issue here. Can you help me fix the problem?

Describe the bug: I am Getting below error when I'm trying to upgrade from v11 to v15 : SLF4J: Failed toString() invocation on an object of type [com.google.ads.googleads.v15.services.SearchGoogleAdsStreamRequest] Reported exception: java.lang.IllegalAccessError: tried to access method com.google.protobuf.LazyStringArrayList.emptyList()Lcom/google/protobuf/LazyStringArrayList; from class com.google.api.ResourceDescriptor

Steps to Reproduce:

Expected behavior:

Client library version and API version: Client library version: 28.0.0 Google Ads API version: v15 JDK version: 1.8.0

Request/Response Logs:

Request


MethodName: google.ads.googleads.v15.services.GoogleAdsService/SearchStream Endpoint: googleads.googleapis.com:443 Headers: {developer-token=REDACTED, x-goog-api-client=gl-java/1.8.0_392__Private-Build gccl/28.0.0 gapic/28.0.0 gax/2.38.0 grpc/1.59.1 pb/3.21.9} Body: [FAILED toString()] Response

Headers: Metadata(content-disposition=attachment,content-type=application/grpc,date=Mon, 15 Jan 2024 03:01:50 GMT,alt-svc=h3=":443"; ma=2592000,h3-29=":443"; ma=2592000) Body: null Failure message: null Status: Status{code=CANCELLED, description=Failed to read message., cause=java.lang.IllegalAccessError: tried to access method com.google.protobuf.LazyStringArrayList.emptyList()Lcom/google/protobuf/LazyStringArrayList; from class com.google.ads.googleads.v15.resources.Campaign

Full log in here full-ads-api.log

tvc12 commented 8 months ago

This file lists my dependencies in my project. dependencies-tree.log

jradcliff commented 8 months ago

I see the following dependency is pulling in an older version of protobuf-jar:

[INFO] +- com.mysql:mysql-connector-j:jar:8.0.33:compile
[INFO] | \- com.google.protobuf:protobuf-java:jar:3.21.9:compile

Version 28.0.0 of the Google Ads API library for Java has a dependency on protobuf-java version 3.23.2. I recommend upgrading the mysql-connector-j dependency to one that depends on the same version of probotuf-java.

tvc12 commented 7 months ago

Thank you @jradcliff, I upgraded protobuf-Java to 3.23.2. It worked. However, it was a significant change in my project, causing the MySQL and BigQuery test cases to fail. Could you suggest an alternative solution? Thank you very much.

jradcliff commented 7 months ago

Hi,

Glad to hear that fixed it. The only alternative I can think of is to use our shadow dependency of google-ads-shadow-jar instead of google-ads.

Cheers, Josh