question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bad dependency for `google-cloud-logging` vs `google-cloud-datastore`

See original GitHub issue

For https://github.com/GoogleCloudPlatform/jetty-runtime we are trying to use both google-cloud-logging and google-cloud-datastore, but there appears to be incompatible dependencies.

With a simple pom like:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <name>Google Cloud Example</name>
  <groupId>org.acme</groupId>
  <version>1.0.0</version>
  <artifactId>example</artifactId>
  <packaging>jar</packaging>

  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-logging</artifactId>
      <version>1.0.1</version>
    </dependency>
  </dependencies>
</project>

we get the following dependency:tree:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ example ---
[INFO] org.acme:example:jar:1.0.0
[INFO] \- com.google.cloud:google-cloud-logging:jar:1.0.1:compile
[INFO]    +- io.netty:netty-tcnative-boringssl-static:jar:1.1.33.Fork26:compile
[INFO]    +- com.google.cloud:google-cloud-core:jar:1.0.1:compile
[INFO]    |  +- com.google.guava:guava:jar:19.0:compile
[INFO]    |  +- joda-time:joda-time:jar:2.9.2:compile
[INFO]    |  +- org.json:json:jar:20160810:compile
[INFO]    |  +- com.google.api:api-common:jar:1.0.0:compile
[INFO]    |  +- com.google.api:gax:jar:1.0.0:compile
[INFO]    |  +- com.google.protobuf:protobuf-java-util:jar:3.2.0:compile
[INFO]    |  |  \- com.google.code.gson:gson:jar:2.7:compile
[INFO]    |  +- com.google.api.grpc:proto-google-common-protos:jar:0.1.9:compile
[INFO]    |  \- com.google.api.grpc:proto-google-iam-v1:jar:0.1.9:compile
[INFO]    +- com.google.cloud:google-cloud-core-grpc:jar:1.0.1:compile
[INFO]    |  +- com.google.protobuf:protobuf-java:jar:3.2.0:compile
[INFO]    |  \- io.grpc:grpc-protobuf:jar:1.2.0:compile
[INFO]    |     \- io.grpc:grpc-protobuf-lite:jar:1.2.0:compile
[INFO]    +- com.google.api:gax-grpc:jar:0.16.0:compile
[INFO]    |  +- com.google.auth:google-auth-library-oauth2-http:jar:0.4.0:compile
[INFO]    |  |  +- com.google.http-client:google-http-client:jar:1.19.0:compile
[INFO]    |  |  |  \- org.apache.httpcomponents:httpclient:jar:4.0.1:compile
[INFO]    |  |  |     +- org.apache.httpcomponents:httpcore:jar:4.0.1:compile
[INFO]    |  |  |     +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO]    |  |  |     \- commons-codec:commons-codec:jar:1.3:compile
[INFO]    |  |  \- com.google.http-client:google-http-client-jackson2:jar:1.19.0:compile
[INFO]    |  |     \- com.fasterxml.jackson.core:jackson-core:jar:2.1.3:compile
[INFO]    |  +- com.google.auto.value:auto-value:jar:1.2:compile
[INFO]    |  +- org.threeten:threetenbp:jar:1.3.3:compile
[INFO]    |  \- com.google.code.findbugs:jsr305:jar:3.0.0:compile
[INFO]    +- com.google.api.grpc:proto-google-cloud-logging-v2:jar:0.1.9:compile
[INFO]    +- io.grpc:grpc-netty:jar:1.2.0:compile
[INFO]    |  +- io.grpc:grpc-core:jar:1.2.0:compile (version selected from constraint [1.2.0,1.2.0])
[INFO]    |  |  +- com.google.errorprone:error_prone_annotations:jar:2.0.11:compile
[INFO]    |  |  +- io.grpc:grpc-context:jar:1.2.0:compile
[INFO]    |  |  \- com.google.instrumentation:instrumentation-api:jar:0.3.0:compile
[INFO]    |  +- io.netty:netty-codec-http2:jar:4.1.8.Final:compile (version selected from constraint [4.1.8.Final,4.1.8.Final])
[INFO]    |  |  +- io.netty:netty-codec-http:jar:4.1.8.Final:compile
[INFO]    |  |  |  \- io.netty:netty-codec:jar:4.1.8.Final:compile
[INFO]    |  |  \- io.netty:netty-handler:jar:4.1.8.Final:compile
[INFO]    |  |     \- io.netty:netty-buffer:jar:4.1.8.Final:compile
[INFO]    |  |        \- io.netty:netty-common:jar:4.1.8.Final:compile
[INFO]    |  \- io.netty:netty-handler-proxy:jar:4.1.8.Final:compile
[INFO]    |     +- io.netty:netty-transport:jar:4.1.8.Final:compile
[INFO]    |     |  \- io.netty:netty-resolver:jar:4.1.8.Final:compile
[INFO]    |     \- io.netty:netty-codec-socks:jar:4.1.8.Final:compile
[INFO]    +- io.grpc:grpc-stub:jar:1.2.0:compile
[INFO]    \- io.grpc:grpc-auth:jar:1.2.0:compile
[INFO]       \- com.google.auth:google-auth-library-credentials:jar:0.4.0:compile

Note that 0.4.0 version of com.google.auth:google-auth-library-oauth2-http:jar

The google-cloud-datastore version depends instead on 0.6.1 as you can see in the following dependency:tree:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ example ---
[INFO] org.acme:example:jar:1.0.0
[INFO] \- com.google.cloud:google-cloud-datastore:jar:1.0.1:compile
[INFO]    +- com.google.cloud:google-cloud-core:jar:1.0.1:compile
[INFO]    |  +- com.google.guava:guava:jar:19.0:compile
[INFO]    |  +- joda-time:joda-time:jar:2.9.2:compile
[INFO]    |  +- org.json:json:jar:20160810:compile
[INFO]    |  +- com.google.api:api-common:jar:1.0.0:compile
[INFO]    |  |  +- com.google.auto.value:auto-value:jar:1.1:compile
[INFO]    |  |  \- com.google.code.findbugs:jsr305:jar:3.0.0:compile
[INFO]    |  +- com.google.api:gax:jar:1.0.0:compile
[INFO]    |  |  \- org.threeten:threetenbp:jar:1.3.3:compile
[INFO]    |  +- com.google.protobuf:protobuf-java-util:jar:3.2.0:compile
[INFO]    |  |  \- com.google.code.gson:gson:jar:2.7:compile
[INFO]    |  +- com.google.api.grpc:proto-google-common-protos:jar:0.1.9:compile
[INFO]    |  \- com.google.api.grpc:proto-google-iam-v1:jar:0.1.9:compile
[INFO]    +- com.google.cloud:google-cloud-core-http:jar:1.0.1:compile
[INFO]    |  +- com.google.auth:google-auth-library-credentials:jar:0.6.1:compile
[INFO]    |  +- com.google.auth:google-auth-library-oauth2-http:jar:0.6.1:compile
[INFO]    |  |  \- com.google.http-client:google-http-client-jackson2:jar:1.19.0:compile
[INFO]    |  |     \- com.fasterxml.jackson.core:jackson-core:jar:2.1.3:compile
[INFO]    |  +- com.google.http-client:google-http-client:jar:1.21.0:compile
[INFO]    |  |  \- org.apache.httpcomponents:httpclient:jar:4.0.1:compile
[INFO]    |  |     +- org.apache.httpcomponents:httpcore:jar:4.0.1:compile
[INFO]    |  |     +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO]    |  |     \- commons-codec:commons-codec:jar:1.3:compile
[INFO]    |  +- com.google.oauth-client:google-oauth-client:jar:1.21.0:compile
[INFO]    |  +- com.google.api-client:google-api-client:jar:1.21.0:compile
[INFO]    |  +- com.google.http-client:google-http-client-appengine:jar:1.21.0:compile
[INFO]    |  \- com.google.http-client:google-http-client-jackson:jar:1.21.0:compile
[INFO]    |     \- org.codehaus.jackson:jackson-core-asl:jar:1.9.11:compile
[INFO]    +- com.google.cloud.datastore:datastore-v1-protos:jar:1.3.0:compile
[INFO]    |  \- com.google.protobuf:protobuf-java:jar:3.0.0:compile
[INFO]    +- com.google.cloud.datastore:datastore-v1-proto-client:jar:1.3.0:compile
[INFO]    |  \- com.google.http-client:google-http-client-protobuf:jar:1.20.0:compile
[INFO]    \- com.google.api.grpc:grpc-google-common-protos:jar:0.1.9:compile
[INFO]       +- io.grpc:grpc-stub:jar:1.2.0:compile
[INFO]       |  \- io.grpc:grpc-core:jar:1.2.0:compile
[INFO]       |     +- com.google.errorprone:error_prone_annotations:jar:2.0.11:compile
[INFO]       |     +- io.grpc:grpc-context:jar:1.2.0:compile
[INFO]       |     \- com.google.instrumentation:instrumentation-api:jar:0.3.0:compile
[INFO]       \- io.grpc:grpc-protobuf:jar:1.2.0:compile
[INFO]          \- io.grpc:grpc-protobuf-lite:jar:1.2.0:compile

If a pom lists both datastore and logging dependencies, for some reason the 0.4.0 version is picked, which fails to work with datastore (@janbartel can you comment with the exception you are getting).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
shinfancommented, May 10, 2017

I have excluded both google-auth-library-credentials and google-auth-library-oauth2-http in my pom and my sample application executes without exception.

This is the dependency section my pom:

<dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-logging</artifactId>
      <version>1.0.1</version>
      <exclusions>
        <exclusion>
          <groupId>com.google.auth</groupId>
          <artifactId>google-auth-library-oauth2-http</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.auth</groupId>
          <artifactId>google-auth-library-credentials</artifactId>
        </exclusion>
      </exclusions> 
    </dependency>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-datastore</artifactId>
      <version>1.0.1</version>
      <exclusions>
        <exclusion>
          <groupId>com.google.auth</groupId>
          <artifactId>google-auth-library-oauth2-http</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.auth</groupId>
          <artifactId>google-auth-library-credentials</artifactId>
        </exclusion>
      </exclusions> 
    </dependency>
    <dependency>
      <groupId>com.google.auth</groupId>
      <artifactId>google-auth-library-oauth2-http</artifactId>
      <version>0.6.1</version>
     </dependency>
     <dependency>
      <groupId>com.google.auth</groupId>
      <artifactId>google-auth-library-credentials</artifactId>
      <version>0.6.1</version>
    </dependency>
  </dependencies>

You also can view and download the entire sample application here

1reaction
vam-googlecommented, May 23, 2017

https://github.com/googleapis/gax-java/pull/310 should fix the problem. The next released google-cloud-java library should contain the fix.

Before that, the workarounds are:

  • Switch order in which the dependencies are mentioned in the pom: datastore dependency should go before logging (yes, order matters for maven dependency resolution) - this should fix the issue
  • Alternatively you can add the following in the module pom, to explicitly tell maven which versions to use for transitive dependencies:
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.auth</groupId>
        <artifactId>google-auth-library-credentials</artifactId>
        <version>0.6.1</version>
      </dependency>
      <dependency>
        <groupId>com.google.auth</groupId>
        <artifactId>google-auth-library-oauth2-http</artifactId>
        <version>0.6.1</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Google.Cloud.Diagnostics.Common
Google.Cloud.Diagnostics.Common is a .NET Core instrumentation library for Google Logging, Error Reporting and Tracing.
Read more >
Google Cloud Platform - The Good, Bad, and Ugly (It's Mostly ...
I've split my thoughts below into good, meh, bad, ugly, and opportunities ... Google Cloud Storage, has consistent lists and gets, Cloud Key ......
Read more >
What is wrong with google-cloud-storage Guava dependency ...
Solution is to shade Guava (and any other dependencies) within your job jar. Share.
Read more >
Cloud Storage for Firebase - Google
Cloud Storage for Firebase is built for app developers who need to store and serve user-generated content, such as photos or videos.
Read more >
Change the severity of (platform emitting) request log ...
I think We need some method of propagate (or modify) severity from app. I want to graduate from proprietary AppEngine APIs. https://cloud.google.com/appengine/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found