adwords-axis-2.8.0.jar transitive dependencies cause Caused by: java.lang.ClassCastException: com.google.common.io.ByteSource$ByteArrayByteSource cannot be cast to com.google.common.io.InputSupplier

97 views
Skip to first unread message

Andy Lin

unread,
Dec 14, 2015, 8:58:24 AM12/14/15
to AdWords API Forum
In my build.gradle, I have those 2 adword api jars as dependencies, when I pool the results from the batchJobs, I get the following execptions, which versions of guava-#.jar and guava-jdk5-#.jar I should explicit specify in my build.gradle?  It seems like transitive jar dependencies' version conflict problems.  thanks for your answer

compile('com.google.api-ads:ads-lib:2.8.0')
compile('com.google.api-ads:adwords-axis:2.8.0')

 if (batchJob.getDownloadUrl() != null && batchJob.getDownloadUrl().getUrl() != null) {
            BatchJobMutateResponse mutateResponse =
                batchJobHelper.downloadBatchJobMutateResponse(batchJob.getDownloadUrl().getUrl());
            System.out.printf("Downloaded results from %s:%n", batchJob.getDownloadUrl().getUrl());
            for (MutateResult mutateResult : mutateResponse.getMutateResults()) {
              String outcome = mutateResult.getErrorList() == null ? "SUCCESS" : "FAILURE";
              System.out.printf("  Operation [%d] - %s%n", mutateResult.getIndex(), outcome);
            }
          }
 


Caused by: java.lang.ClassCastException: com.google.common.io.ByteSource$ByteArrayByteSource cannot be cast to com.google.common.io.InputSupplier
    at com.google.common.io.MultiInputStream.advance(MultiInputStream.java:65) ~[guava-jdk5-13.0.jar:na]
    at com.google.common.io.MultiInputStream.<init>(MultiInputStream.java:44) ~[guava-jdk5-13.0.jar:na]
    at com.google.common.io.ByteSource$ConcatenatedByteSource.openStream(ByteSource.java:653) ~[guava-19.0-rc2.jar:na]
    at com.google.api.ads.adwords.axis.utils.AxisDeserializer.buildWrappedInputStream(AxisDeserializer.java:160) ~[adwords-axis-2.8.0.jar:na]
    at com.google.api.ads.adwords.axis.utils.AxisDeserializer.deserializeBatchJobMutateResults(AxisDeserializer.java:113) ~[adwords-axis-2.8.0.jar:na]
    at com.google.api.ads.adwords.axis.utils.v201509.batchjob.BatchJobHelper.downloadBatchJobMutateResponse(BatchJobHelper.java:101) ~[adwords-axis-2.8.0.jar:na]

Josh Radcliff (AdWords API Team)

unread,
Dec 14, 2015, 3:57:29 PM12/14/15
to AdWords API Forum
Hi,

I would recommend not including the guava-jdk5 dependency in gradle. As announced in November of last year, the minimum JRE version required for the library is 1.6, so the Java 5 backport shouldn't be required, and may actually cause problems.

For the com.google.guava/guava dependency, I'd recommend using 19.0-rc2 (the version referenced in the ads_lib pom.xml).

Thanks,
Josh, AdWords API Team

Andy Lin

unread,
Dec 28, 2015, 5:31:14 PM12/28/15
to AdWords API Forum
Yes, it works after I excluded guava-jdk5-#.jar from all the google api.  My project also use google drive, oauth-client, and api-clients.  Some of these have the transitive dependency on guava-jdk5-#.jar

This is a example how I did it.

compile('com.google.api-client:google-api-client:1.20.0'){

    exclude group: 'com.google.guava', module: 'guava-jdk5' 

    }

    compile('com.google.oauth-client:google-oauth-client-jetty:1.20.0'){

    exclude group: 'com.google.guava', module: 'guava-jdk5' 

    }

    compile('com.google.apis:google-api-services-drive:v2-rev170-1.20.0'){

    exclude group: 'com.google.guava', module: 'guava-jdk5' 

    }


On Monday, December 14, 2015 at 8:58:24 AM UTC-5, Andy Lin wrote:
Reply all
Reply to author
Forward
0 new messages