Scala:java.lang.VerifyError - 函数参数不兼容 - 运行时错误
我在混合 Java/Scala 项目上使用 Scala 的 MongoDB Casbah 库。
这段代码在 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 ")
}
})
当我通过 Ant 构建运行它时(与我在 REPL 中使用的类路径相同),它编译得很好,但我在运行时得到了这个:
[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)
...
该堆栈跟踪点的最后一行到“val q = ...”行。
我使用 Scala 2.9.0-1 构建了 Casbah 库 [2.9.0-1-2.2.0-SNAPSHOT],并使用相同的库来运行它。我怀疑这个错误与使用不兼容版本的 Scala 构建的类路径上的某些库有关,但我在任何地方都找不到它,而且我无法解释为什么相同的代码可以在 REPL 中使用相同的类路径。如果有任何关于在哪里进一步挖掘的想法,我将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您的第三方库之一与旧版本的 Scala 链接:
[java] at com.enspire.hive.elements.pub.SelectionJson$$anonfun$1.apply(SelectionJson.scala:17)
似乎是根飞入错误的连杆。
Looks like one of your third party libraries is linked against an old version of Scala:
[java] at com.enspire.hive.elements.pub.SelectionJson$$anonfun$1.apply(SelectionJson.scala:17)
Appears to be the root of the flit down into the wrong linkage.