Reputation: 81
My JUnit test case breaks after upgrading the datastax Cassandra driver to 3.0.1. A check was added to ensure that Google guava version 16.0.1 is used as described on the Datastax upgrade page: point 3.
I explicitly included a dependency on google guava, recent version 19.0, but this doesn't seem to help because the test case still throws the guava version exception.
To clarify, there is no issue compiling the code, only when executing the unit test. I fail to understand why an older version of guava gets picked up in the classpath when 19.0 is explicitly added in pom.xml? What have I done wrong?
Several other posts such as this one describe solutions for Spark and Hadoop, but this is a WAR project so I ran a dependency tree in maven and see that 19.0 replaces the recommended 16.0.1.
[INFO] +- com.google.guava:guava:jar:19.0:compile
[INFO] +- com.datastax.cassandra:cassandra-driver-core:jar:3.0.1:compile
...
[INFO] | +- (com.google.guava:guava:jar:16.0.1:compile - omitted for conflict with 19.0)
Detailed info starts here
The exception stack trace:
java.lang.ExceptionInInitializerError
at com.datastax.driver.core.Cluster$Builder.build(Cluster.java:1274)
at org.cassandraunit.spring.AbstractCassandraUnitTestExecutionListener.startServer(AbstractCassandraUnitTestExecutionListener.java:61)
at org.cassandraunit.spring.CassandraUnitDependencyInjectionTestExecutionListener.prepareTestInstance(CassandraUnitDependencyInjectionTestExecutionListener.java:21)
at ...
Caused by: java.lang.IllegalStateException: Detected Guava issue #1635 which indicates that a version of Guava less than 16.01 is in use. This introduces codec resolution issues and potentially other incompatibility issues in the driver. Please upgrade to Guava 16.01 or later.
at com.datastax.driver.core.SanityChecks.checkGuava(SanityChecks.java:62)
at com.datastax.driver.core.SanityChecks.check(SanityChecks.java:36)
at com.datastax.driver.core.Cluster.<clinit>(Cluster.java:68)
... 25 more
If interested, check out the source code for what the check does.
Pom.xml relevant sections are:
<!-- Spring data cassandra -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
<version>${org.springframework.data.cassandra.version}</version>
</dependency>
<!-- Cassandra in memory unit testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit-spring</artifactId>
<version>2.1.3.2-SNAPSHOT</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit-shaded</artifactId>
<version>2.1.3.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hectorclient</groupId>
<artifactId>hector-core</artifactId>
<version>2.0-0</version>
<optional>true</optional>
<scope>test</scope>
</dependency>
<!-- Datastax Cassandra Java driver -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.0.1</version>
</dependency>
This is the dependency tree from maven. Copied over relevant sections only because it is (too) huge.
...
[INFO] +- com.google.api-client:google-api-client:jar:1.20.0:compile
[INFO] | +- com.google.oauth-client:google-oauth-client:jar:1.20.0:compile
[INFO] | | +- com.google.http-client:google-http-client:jar:1.20.0:compile
[INFO] | | | +- (com.google.code.findbugs:jsr305:jar:1.3.9:compile - omitted for duplicate)
[INFO] | | | \- (org.apache.httpcomponents:httpclient:jar:4.0.1:compile - omitted for conflict with 4.3)
[INFO] | | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] | +- com.google.http-client:google-http-client-jackson2:jar:1.20.0:compile
[INFO] | | +- (com.google.http-client:google-http-client:jar:1.20.0:compile - omitted for duplicate)
[INFO] | | \- (com.fasterxml.jackson.core:jackson-core:jar:2.1.3:compile - omitted for conflict with 2.3.0)
[INFO] | \- com.google.guava:guava-jdk5:jar:13.0:compile
...
[INFO] +- org.springframework.data:spring-data-cassandra:jar:1.3.2.RELEASE:compile
[INFO] | +- org.springframework.data:spring-cql:jar:1.3.2.RELEASE:compile
[INFO] | | +- (org.springframework:spring-context:jar:4.1.9.RELEASE:compile - omitted for conflict with 4.1.6.RELEASE)
[INFO] | | +- (org.springframework:spring-beans:jar:4.1.9.RELEASE:compile - omitted for conflict with 4.1.6.RELEASE)
[INFO] | | +- (org.springframework:spring-core:jar:4.1.9.RELEASE:compile - omitted for conflict with 4.1.6.RELEASE)
[INFO] | | +- (org.springframework:spring-expression:jar:4.1.9.RELEASE:compile - omitted for conflict with 4.1.6.RELEASE)
[INFO] | | +- org.springframework:spring-tx:jar:4.1.9.RELEASE:compile
[INFO] | | | +- (org.springframework:spring-beans:jar:4.1.9.RELEASE:compile - omitted for conflict with 4.1.6.RELEASE)
[INFO] | | | \- (org.springframework:spring-core:jar:4.1.9.RELEASE:compile - omitted for conflict with 4.1.6.RELEASE)
[INFO] | | +- (org.springframework.data:spring-data-commons:jar:1.11.2.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (com.datastax.cassandra:cassandra-driver-dse:jar:2.1.5:compile - omitted for duplicate)
[INFO] | | +- (com.google.guava:guava:jar:14.0:compile - omitted for conflict with 19.0)
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.13:compile - omitted for conflict with 1.7.5)
[INFO] | | \- (org.slf4j:jcl-over-slf4j:jar:1.7.13:runtime - omitted for conflict with 1.7.5)
[INFO] | +- (org.springframework:spring-expression:jar:4.1.9.RELEASE:compile - omitted for conflict with 4.1.6.RELEASE)
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.11.2.RELEASE:compile
[INFO] | | +- (org.springframework:spring-core:jar:4.1.9.RELEASE:compile - omitted for conflict with 4.1.6.RELEASE)
[INFO] | | +- (org.springframework:spring-beans:jar:4.1.9.RELEASE:compile - omitted for conflict with 4.1.6.RELEASE)
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.13:compile - omitted for conflict with 1.7.5)
[INFO] | | \- (org.slf4j:jcl-over-slf4j:jar:1.7.13:runtime - omitted for conflict with 1.7.5)
[INFO] | +- com.datastax.cassandra:cassandra-driver-dse:jar:2.1.5:compile
[INFO] | | \- (com.datastax.cassandra:cassandra-driver-core:jar:2.1.5:compile - omitted for conflict with 3.0.1)
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.13:compile - omitted for conflict with 1.7.5)
[INFO] | \- (org.slf4j:jcl-over-slf4j:jar:1.7.13:runtime - omitted for conflict with 1.7.5)
...
[INFO] +- org.hectorclient:hector-core:jar:2.0-0:test
[INFO] | +- (commons-lang:commons-lang:jar:2.4:test - omitted for duplicate)
[INFO] | +- commons-pool:commons-pool:jar:1.5.3:test
[INFO] | +- org.apache.cassandra:cassandra-thrift:jar:2.0.4:test
[INFO] | | +- (org.apache.commons:commons-lang3:jar:3.1:test - omitted for duplicate)
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.2:test - omitted for conflict with 1.7.12)
[INFO] | | \- (org.apache.thrift:libthrift:jar:0.9.1:test - omitted for conflict with 0.9.2)
[INFO] | +- (com.google.guava:guava:jar:14.0:compile - scope updated from test; omitted for duplicate)
[INFO] | +- (org.slf4j:slf4j-api:jar:1.6.1:test - omitted for conflict with 1.7.12)
[INFO] | +- com.github.stephenc.eaio-uuid:uuid:jar:3.2.0:test
[INFO] | +- com.ecyrd.speed4j:speed4j:jar:0.9:test
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.6.1:test - omitted for conflict with 1.7.12)
[INFO] | \- com.yammer.metrics:metrics-core:jar:2.2.0:test
[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.2:test - omitted for conflict with 1.7.12)
[INFO] +- com.google.guava:guava:jar:19.0:compile
[INFO] +- com.datastax.cassandra:cassandra-driver-core:jar:3.0.1:compile
[INFO] | +- io.netty:netty-handler:jar:4.0.33.Final:compile
[INFO] | | +- io.netty:netty-buffer:jar:4.0.33.Final:compile
[INFO] | | | \- io.netty:netty-common:jar:4.0.33.Final:compile
[INFO] | | +- io.netty:netty-transport:jar:4.0.33.Final:compile
[INFO] | | | \- (io.netty:netty-buffer:jar:4.0.33.Final:compile - omitted for duplicate)
[INFO] | | \- io.netty:netty-codec:jar:4.0.33.Final:compile
[INFO] | | \- (io.netty:netty-transport:jar:4.0.33.Final:compile - omitted for duplicate)
[INFO] | +- (com.google.guava:guava:jar:16.0.1:compile - omitted for conflict with 19.0)
[INFO] | \- io.dropwizard.metrics:metrics-core:jar:3.1.2:compile
[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.7.12)
Upvotes: 0
Views: 1339
Reputation: 4536
As you pointed out yourself, the culprit is indeed google-api-client
which depends on a non-standard guava jar named guava-jdk5
, which is bringing Guava 13.0 to your classpath.
Try excluding it:
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.20.0</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava-jdk5</artifactId>
</exclusion>
</exclusions>
</dependency>
Upvotes: 1