I'm trying to get started with Datomisca, but the getting started code results in an NoSuchMethodError
.
Here's a compact snippet that reproduces that.
package tw.txstream.flinktest
import scala.concurrent.ExecutionContext.Implicits.global
import datomisca._
object DatomicTest {
def main(args: Array[String]){
val uri = "datomic:dev://localhost:4334/test"
// ensure clean DB
println("Deleted DB? " + Datomic.deleteDatabase(uri))
println("Created DB? " + Datomic.createDatabase(uri))
implicit val conn = Datomic.connect(uri)
Datomic.transact(Schema.txDataA) map { tx =>
println("Transacted")
}
}
}
object Schema {
object ns {
val ns1 = Namespace("ns1")
}
val attr1 = Attribute(
ns.ns1 / "attr1",
SchemaType.string,
Cardinality.one
).withDoc("attr1")
val ident1 = AddIdent(ns.ns1 / "ident1")
val txDataA: Seq[TxData] = Seq(attr1)
val txDataB: Seq[TxData] = Seq(ident1)
}
The exception I get:
Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;
at datomisca.Attribute.toAddOps$lzycompute(Attribute.scala:80)
at datomisca.Attribute.toAddOps(Attribute.scala:78)
at datomisca.Attribute.toTxData(Attribute.scala:98)
at datomisca.Connection$$anonfun$transact$extension$1.apply(Connection.scala:152)
at datomisca.Connection$$anonfun$transact$extension$1.apply(Connection.scala:151)
at scala.collection.immutable.List.foreach(List.scala:318)
at datomisca.Connection$.transact$extension(Connection.scala:151)
at datomisca.TransactOps$class.transact(TransactOps.scala:53)
at datomisca.Datomic$.transact(Datomic.scala:31)
Transacting Schema.txDataB
instead of Schema.txDataA
however works fine. So it seems the error has something to do with Datomisca's Attribute()
.
What's the problem and how to fix this?
This was a scala version issue.
Originally, I used the following:
<dependency>
<groupId>com.github.dwhjames</groupId>
<artifactId>datomisca_2.11</artifactId>
<version>0.7.0</version>
</dependency>
Changing artifactId
to "datomisca_2.10" fixed it for me.