3

I am getting a strange error with sbt run for a Spray example app I wrote, it compiles fine, and I only get the error on my personal computer because it works fine on another computer.

Here's what I think is the relevant source, it's the template code from Spray sample code but I don't think it's the cause.

package spray.examples

import akka.actor.{ActorSystem, Props}
import akka.io.IO
import spray.can.Http

object Boot extends App {

  implicit val system = ActorSystem()

  // the handler actor replies to incoming HttpRequests
  val handler = system.actorOf(Props[DemoServiceActor], name = "handler")

  IO(Http) ! Http.Bind(handler, interface = "localhost", port = 8080)
}

Here's the stack trace

Uncaught error from thread [default-akka.actor.default-dispatcher-3] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[default]
java.lang.VerifyError: (class: spray/can/server/HttpListener, method: <init> signature: (Lakka/actor/ActorRef;Lspray/can/Http$Bind;Lspray/can/HttpExt$Settings;)V) Incompatible argument to function
    at spray.can.HttpManager$$anonfun$receive$1$$anonfun$applyOrElse$1.apply(HttpManager.scala:65)
    at spray.can.HttpManager$$anonfun$receive$1$$anonfun$applyOrElse$1.apply(HttpManager.scala:65)
    at akka.actor.CreatorFunctionConsumer.produce(Props.scala:369)
    at akka.actor.Props.newActor(Props.scala:323)
    at akka.actor.ActorCell.newActor(ActorCell.scala:534)
    at akka.actor.ActorCell.create(ActorCell.scala:560)
    at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:425)
    at akka.actor.ActorCell.systemInvoke(ActorCell.scala:447)
    at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:262)
    at akka.dispatch.Mailbox.run(Mailbox.scala:218)
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

As indicated in the comments, this is likely a classpath issue but I don't know how to debug that. Coincidentally, or not, this happened after I upgraded from stock Mac OS X Java 6 to Java 7, I have Java 7 on both machines. Any insights will be much appreciated.

In case this might help, here's the classpath dump from sbt console, it's the same for compile and runtime

List(Attributed(/Users/bob/projects/spray-file-upload/target/scala-2.10/classes), 
Attributed(/Users/bob/.sbt/0.12.4/boot/scala-2.10.2/lib/scala-library.jar), 
Attributed(/Users/bob/.ivy2/cache/com.typesafe.akka/akka-actor_2.10/jars/akka-actor_2.10-
2.2.0.jar), Attributed(/Users/bob/.ivy2/cache/com.typesafe/config/bundles/config-1.0.2.jar), 
Attributed(/Users/bob/.ivy2/cache/io.spray/spray-json_2.10/jars/spray-json_2.10-1.2.5.jar), 
Attributed(/Users/bob/.ivy2/cache/org.parboiled/parboiled-scala_2.10/bundles/parboiled-
scala_2.10-1.1.5.jar), Attributed(/Users/bob/.ivy2/cache/org.parboiled/parboiled-
core/bundles/parboiled-core-1.1.5.jar), Attributed(/Users/bob/.ivy2/cache/io.spray/spray-
can/jars/spray-can-1.2-M8.jar), Attributed(/Users/bob/.ivy2/cache/io.spray/spray-
io/jars/spray-io-1.2-M8.jar), Attributed(/Users/bob/.ivy2/cache/io.spray/spray-
util/jars/spray-util-1.2-M8.jar), Attributed(/Users/bob/.ivy2/cache/io.spray/spray-
http/jars/spray-http-1.2-M8.jar), Attributed(/Users/bob/.ivy2/cache/io.spray/spray-
httpx/jars/spray-httpx-1.2-M8.jar), 
Attributed(/Users/bob/.ivy2/cache/org.jvnet.mimepull/mimepull/jars/mimepull-1.9.2.jar), 
Attributed(/Users/bob/.ivy2/cache/io.spray/spray-routing/jars/spray-routing-1.2-M8.jar), 
Attributed(/Users/bob/.ivy2/cache/com.chuusai/shapeless_2.10/jars/shapeless_2.10-1.2.4.jar))

If anyone cares to try a fresh compile with Java 7 and then sbt run, feel free to grab it from the repo.

Bob
  • 8,424
  • 17
  • 72
  • 110
  • Yep. That's a stack trace alright. Not sure what you're expecting anyone to do without the relevant source code though... – John3136 Aug 08 '13 at 04:06
  • Fair enough, I included what I think it is the relevant part of my source but I am not sure exactly. If you look at the stack trace, it didn't refer to any of my code. Digging around indicates that it might be a conflict between compile vs runtime libraries http://stackoverflow.com/questions/100107/reasons-of-getting-a-java-lang-verifyerror – Bob Aug 08 '13 at 04:19
  • Cursory research suggests that a VerifyError indicates a problem with your classpath, not with your code. When you run on a different computer, is it possible that different jars are involved? – Chris Martin Aug 08 '13 at 04:20
  • @ChristopherMartin yes I agree it's likely a classpath issue but I don't know how to debug that – Bob Aug 08 '13 at 04:22
  • The question I asked was intended to be the first step to debug that. Where are your jars coming from: What are you using to build, and what are you using to deploy? – Chris Martin Aug 08 '13 at 04:34
  • If you suspect switching to Java 7 might have caused the problem, why not try compiling and/or running with Java 6 again to find out? – Chris Martin Aug 08 '13 at 04:36
  • I am using paulp sbt-extras script to compile and run, the only resolver I have is from Spray repo `val resolver = Seq("Spray Repo" at "http://repo.spray.io")`. I also tried to revert back to JDK 1.6 but it still has the same issue. I am wondering if the JDK 1.7 upgrade messed something up. – Bob Aug 08 '13 at 04:40
  • I use Java 7. Did you try to clean and recompile from scratch? – Lord of the Goo Aug 08 '13 at 06:10
  • @LordoftheGoo yes many times, I even deleted the ivy cache and related sbt folders. – Bob Aug 08 '13 at 06:15
  • Java 7 on Windows 7 gives me the VerifyError too. So I can reproduce the problem. – stefan.schwetschke Aug 08 '13 at 07:18

1 Answers1

11

Unfortunately, 1.2-M8 is not compatible with Akka 2.2.0 final. Either use Akka 2.2.0-RC1 or upgrade to a more recent nightly build of spray 1.2.

UPDATE: Also, by now the final version has been released, so you can use version 1.2.0 with the latest Akka 2.2.3.

jrudolph
  • 8,307
  • 4
  • 32
  • 50
  • TYVM! That was so not obvious, it also explains why it works on my other computer as I am using Akka 2.2.0-RC2 there. – Bob Aug 08 '13 at 18:15
  • This answer was a lifesaver. I'm in the process of learning and was pretty confused. – squarism Sep 07 '13 at 22:33
  • We already improved the documentation in that regard, but the new version is not yet online :( – jrudolph Sep 08 '13 at 07:56