I'm trying to get my first Scala + Play! application working, and I encounter this problem when trying to access my application (on port 9000) :
not found: type Promise
on this line:
val page: Promise[play.api.libs.ws.Response] = WS.url(googleApiUrl).get()
Those are my imports:
import play.api._
import play.api.mvc._
import play.api.libs.ws._
import play.api.libs.ws.Response
import play.api.http
import play.api.libs.concurrent._
import play.api.libs._
Am I missing something here ?
Those are logs on the console:
sbt.PlayExceptions$CompilationException: Compilation error[not found: type Promise]
at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:322) ~[na:na]
at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:322) ~[na:na]
at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:322) ~[na:na]
at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:319) ~[na:na]
at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
Play2.1 use Scala Future instead of play Promise.
Check the migration guide for more informations, chapter "Play's Promise to become Scala's Future".
A simple exemple give something like that :
import play.api._
import play.api.mvc._
import play.api.libs.ws._
import play.api.libs.concurrent._
import play.api.libs.concurrent.Execution.Implicits._
def myAction() = Action {
Async {
WS.url(googleApiUrl).get.map(response => Ok("what you want here"))
}
}
You can check this exemple with a more complexe use of WS api.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With