Scala 2.10 and Akka 2.0 and 2.1 import problems (Await, Future, Duration)

As a quick note, import statements that used to be like this with Akka 2.0:

import akka.dispatch.Await
import akka.dispatch.Future
import akka.util.duration._

are now like this with Akka 2.1 and Scala 2.10.x:

import scala.concurrent.{Await, Future}
import scala.concurrent.duration._

The Duration object in Akka 2.0 has also been moved, and it’s now included with the scala.concurrent.duration._ import statement.

If you’re seeing compiler error messages like this when trying to compile your Scala 2.10 and Akka 2.1 project:

object Await is not a member of package akka.dispatch

you (probably) have this problem, and changing your import statements as shown will solve your problem.

Follow-up

You may also need this import statement for your Future expressions:

import scala.concurrent.ExecutionContext.Implicits.global

If you are using the Scala IDE project with Eclipse, it gives you part of that information, but not all of it.

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.