I'm using the MongoDB Casbah libraries for Scala on a mixed Java/Scala project.
This code works fine in the REPL:
studentCollection.distinct("districtlea").foreach(x => {
println(x)
val q = MongoDBObject("districtlea" -> x)
val studentWithDistrict = studentCollection.findOne(q)
studentWithDistrict match {
case Some(s) => println(s.getAs[String]("districtname").getOrElse("NO DISTRICT NAME FOUND FOR LEA " + x))
case None => println("NO DISTRICT FOUND WITH LEA ")
}
})
When I run it via my Ant build (with the same classpath as the one I use in the REPL), it compiles fine, but I get this at runtime:
[java] java.lang.VerifyError: (class: scala/collection/immutable/List, method: ms$1 signature: (Lscala/collection/immutable/List;Lscala/Function2;)Lscala/collection/immutable/List;) Incompatible argument to function
[java] at scala.sys.SystemProperties$.propertyHelp(SystemProperties.scala:57)
[java] at scala.sys.SystemProperties$.addHelp(SystemProperties.scala:59)
[java] at scala.sys.SystemProperties$.bool(SystemProperties.scala:63)
[java] at scala.sys.SystemProperties$.noTraceSupression(SystemProperties.scala:75)
[java] at scala.util.control.NoStackTrace$class.fillInStackTrace(NoStackTrace.scala:21)
[java] at scala.util.control.BreakControl.fillInStackTrace(Breaks.scala:77)
[java] at java.lang.Throwable.<init>(Throwable.java:181)
[java] at scala.util.control.BreakControl.<init>(Breaks.scala:77)
[java] at scala.util.control.Breaks.<init>(Breaks.scala:30)
[java] at scala.collection.Traversable$.<init>(Traversable.scala:103)
[java] at scala.collection.Traversable$.<clinit>(Traversable.scala)
[java] at scala.package$.<init>(package.scala:37)
[java] at scala.package$.<clinit>(package.scala)
[java] at scala.Predef$.<init>(Predef.scala:32)
[java] at scala.Predef$.<clinit>(Predef.scala)
[java] at com.enspire.hive.elements.pub.SelectionJson$$anonfun$1.apply(SelectionJson.scala:17)
...
The final line of that stack trace points to the "val q = ..." line.
I built the Casbah libraries [2.9.0-1-2.2.0-SNAPSHOT] using Scala 2.9.0-1 and am using the same for running it. I suspect that this error has something to do with some library on the classpath that was built with an incompatible version of Scala, but I can't find it anywhere, and I can't explain why the same code works in the REPL with the same classpath. I'd appreciate any ideas on where to dig further.