scalaapache-sparkcassandraspark-cassandra-connectorphantom-dsl

Embedded Cassandra with Spark and DataStax Driver Error


We are using following dependencies for our project.

val cassandraConnector = "com.datastax.spark" %% "spark-cassandra-connector" % "2.0.0"
val sparkSql = "org.apache.spark" % "spark-sql_2.11" % "2.2.0"
val phantomDsl = "com.outworkers" % "phantom-dsl_2.11" % "2.15.5"
val cassandraUnit = "org.cassandraunit" % "cassandra-unit" % "3.3.0.2" % "test"

While running the test cases using the command sbt compile test. We are getting following error:-

[error] java.lang.IncompatibleClassChangeError: Class com.datastax.driver.core.DefaultResultSetFuture does not implement the requested interface com.google.common.util.concurrent.ListenableFuture
[error]     at com.google.common.util.concurrent.Futures.addCallback(Futures.java:1776)
[error]     at com.outworkers.phantom.builder.query.execution.PromiseInterface$$anon$1.fromGuava(ExactlyOncePromise.scala:56)
[error]     at com.outworkers.phantom.builder.query.execution.PromiseInterface$$anon$1.fromGuava(ExactlyOncePromise.scala:63)
[error]     at com.outworkers.phantom.builder.query.execution.GuavaAdapter$class.fromGuava(ExecutableStatements.scala:44)
[error]     at com.outworkers.phantom.builder.query.execution.PromiseInterface$$anon$1.fromGuava(ExactlyOncePromise.scala:39)
[error]     at com.outworkers.phantom.builder.query.execution.ExecutableStatements$$anonfun$future$1.apply(ExecutableStatements.scala:112)
[error]     at com.outworkers.phantom.builder.query.execution.ExecutableStatements$$anonfun$future$1.apply(ExecutableStatements.scala:110)
[error]     at scala.collection.immutable.List.foreach(List.scala:381)
[error]     at com.outworkers.phantom.builder.query.execution.ExecutableStatements.future(ExecutableStatements.scala:110)
[error]     at com.outworkers.phantom.ops.DbOps.truncateAsync(DbOps.scala:104)
[error]     at com.outworkers.phantom.ops.DbOps.truncate(DbOps.scala:94)
[error]     at com.knoldus.cassandra.CassandraDatabaseCluster$class.afterAll(CassandraDatabaseCluster.scala:29)
[error]     at com.knoldus.model.PredicateHashingSuite.afterAll(PredicateHashingSuite.scala:7)
[error]     at org.scalatest.BeforeAndAfterAll$$anonfun$1.apply$mcV$sp(BeforeAndAfterAll.scala:225)
[error]     at org.scalatest.Status$$anonfun$withAfterEffect$1.apply(Status.scala:379)
[error]     at org.scalatest.Status$$anonfun$withAfterEffect$1.apply(Status.scala:375)
[error]     at org.scalatest.FailedStatus$.whenCompleted(Status.scala:497)
[error]     at org.scalatest.Status$class.withAfterEffect(Status.scala:375)
[error]     at org.scalatest.FailedStatus$.withAfterEffect(Status.scala:469)
[error]     at org.scalatest.BeforeAndAfterAll$class.run(BeforeAndAfterAll.scala:223)
[error]     at com.knoldus.model.PredicateHashingSuite.run(PredicateHashingSuite.scala:7)
[error]     at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:314)
[error]     at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:480)
[error]     at sbt.TestRunner.runTest$1(TestFramework.scala:102)
[error]     at sbt.TestRunner.run(TestFramework.scala:113)
[error]     at sbt.TestFramework$$anon$2$$anonfun$$lessinit$greater$1.$anonfun$apply$1(TestFramework.scala:258)
[error]     at sbt.TestFramework$.sbt$TestFramework$$withContextLoader(TestFramework.scala:229)
[error]     at sbt.TestFramework$$anon$2$$anonfun$$lessinit$greater$1.apply(TestFramework.scala:258)
[error]     at sbt.TestFramework$$anon$2$$anonfun$$lessinit$greater$1.apply(TestFramework.scala:258)
[error]     at sbt.TestFunction.apply(TestFramework.scala:267)
[error]     at sbt.Tests$.$anonfun$toTask$1(Tests.scala:276)
[error]     at sbt.std.Transform$$anon$3.$anonfun$apply$2(System.scala:44)
[error]     at sbt.std.Transform$$anon$4.work(System.scala:64)
[error]     at sbt.Execute.$anonfun$submit$2(Execute.scala:257)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]     at sbt.Execute.work(Execute.scala:266)
[error]     at sbt.Execute.$anonfun$submit$1(Execute.scala:257)
[error]     at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:167)
[error]     at sbt.CompletionService$$anon$2.call(CompletionService.scala:32)
[error]     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error]     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]     at java.lang.Thread.run(Thread.java:748)

Is there something wrong within dependency?

How can we get rid of this error?

Thanks


Solution

  • That's really interesting, however it's not to do with phantom, it's to do with the Guava Library dependency that somehow ends up clashing with what is on the classpath.

    In short, basically the problem comes from a binary incompatibility/exclusion, so Spark or something else in your classpath overrides the version of Guava in phantom.

    If you print out evictions I can help you further.

    We also offer phantom-sbt as an integrated SBT plugin for Cassandra, which I would suspect as the root cause here, as well as a Docker integration via SBT(pro only feature). Maybe file a GitHub issue for phantom, and we can follow up there more easily as soon as we know which versions clash.