宇宙人
宇宙人

Reputation: 1227

how can spray.io work with scala 2.11.1 akka 2.3.2

I want to use spray.io with scala 2.11.x akka 2.3.x, and I find the following in the Project Info page of spray.io:

spray 1.3.1 is built against Scala 2.10.3 and Akka 2.3.0 as well as Scala 2.11.1 and Akka 2.3.2.

When I use spray-client, I meet some problem and then I find following in the Documentation page of spray.io, that the spray-client is depended on akka 2.10.x:

akka-actor 2.2.x (with ‘provided’ scope, i.e. you need to pull it in yourself)

What does with provided scope mean? How can I use it with other part of the program written in scala 2.11.x akka 2.3.x?

Edit

Following is the simplest use case listed in the documentation page:

import akka.actor.ActorSystem
import scala.concurrent.Future
object main {
  def main(args: Array[String]) {
    import spray.http._
    import spray.client.pipelining._
    implicit val system = ActorSystem()
    import system.dispatcher // execution context for futures
    val pipeline: HttpRequest => Future[HttpResponse] = sendReceive
    val response: Future[HttpResponse] = pipeline(Get("http://spray.io/"))
  }
}

with build.sbt:

scalaVersion := "2.11.1"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.2"
libraryDependencies += "io.spray" % "spray-client" % "1.3.1"

Although this compiles well, but it meets run time error as:

Uncaught error from thread [default-akka.actor.default-dispatcher-2] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[default]
java.lang.NoClassDefFoundError: scala/runtime/AbstractPartialFunction$mcVL$sp
  at ...

Upvotes: 4

Views: 2401

Answers (1)

Ravi Kiran
Ravi Kiran

Reputation: 1139

A provided dependency means, spray requires that dependency but expects the developer to provide it in their build configuration. So, you need to add akka-actor in your build configuration.

If you are using sbt, you can add the following line to you dependencies.

    "com.typesafe.akka"     %% "akka-actor"         % 2.3.2,

Upvotes: 5

Related Questions