[2.1 scala] A couple of issues migrating to 2.1 rc1

1,799 views
Skip to first unread message

sas

unread,
Nov 19, 2012, 9:15:00 AM11/19/12
to play-fr...@googlegroups.com
I'm trying to upgrade an app from play 2.0.4 to play 2.1
 
I got this warning

WARNING
Looks like you are using a deprecated version of Play's SBT Project (PlayProject in project/Build.scala).
We are adding all of the new Play artifacts to your libraryDependencies for now but consider switching to the new API (i.e. play.Project).
For any migration related issues, please consult the migration manual at http://www.playframework.org

So I changed this line in my Build.scala

from
import PlayProject._

to
import play.Project._

then I issued play clean-all, play clean, but the message is still there
--

Then I got an error about akka.util.duration._, I checked akka migration guide at http://doc.akka.io/docs/akka/snapshot/project/migration-guide-2.0.x-2.1.x.html
an changed it to

import scala.concurrent.duration._

then I had

Akka.system.scheduler.schedule(4 hours...

And changed it to 

    import context.dispatcher
    context.system.scheduler.schedule(4 hours...

but context is not found... How can I get the context for play's actor?

--

then I had a couple of minor issues with

value await is not a member of scala.concurrent.Future[play.api.libs.ws.Response]
[error]       get().await.get.body

So I had to replace

val response = WS.url(uri).get().await.get.body

with

    val future = WS.url(uri).get()

    import scala.concurrent.Await
    import scala.concurrent.duration._
    val response = Await.result(future, 5 seconds).body

and then

object codahale is not a member of package com
[error]     com.codahale.jerkson.Json.generate(any)

I had to manually add it to Build.scala

"io.backchat.jerkson" % "jerkson_2.9.2" % "0.7.0"
--

I still couldn't solve the problem with the akka context

Any help will we much appreciated

BTW, here's the scaladoc for akka 2.1 rc2: http://doc.akka.io/api/akka/2.1.0-RC2/#package


is the play 2.1 scaladoc available somewhere online?


saludos

sas



Yann Simon

unread,
Nov 19, 2012, 9:17:12 AM11/19/12
to play-fr...@googlegroups.com
The execution context is resolved by importing:
import scala.concurrent.ExecutionContext.Implicits.global


2012/11/19 sas <ope...@gmail.com>

sas



--
 
 

Pascal Voitot Dev

unread,
Nov 19, 2012, 9:27:43 AM11/19/12
to play-fr...@googlegroups.com
No you shouldn't import this default Scala execution context anymore.
You should import the one described in Migration Guide: https://github.com/playframework/Play20/wiki/Migration
import play.api.libs.concurrent.execution.Implicits._


Pascal



--
 
 

Julien Richard-Foy

unread,
Nov 19, 2012, 9:30:06 AM11/19/12
to play-fr...@googlegroups.com
@pascal It’s been renamed a couple of days ago and the doc does not
seem to be update:
https://github.com/playframework/Play20/commit/2d7df72d4575a881cbe1ef57af53f90b3da2948a
> --
>
>

sas

unread,
Nov 19, 2012, 9:32:46 AM11/19/12
to play-fr...@googlegroups.com
thanks for the prompt reply

as soon as I posted my mail, I saw Peter's message announcing play 2.1

I tried with those imports but I get the following errors:

    import play.api.libs.concurrent._
    import play.api.libs.concurrent.execution.Implicits._
    import scala.concurrent.ExecutionContext.Implicits.global

    context.system.scheduler.schedule(
      4 hours, 24 hours,
      NotificationService.reportActor, ReportNotification()
    );

Global.scala:60: object execution is not a member of package play.api.libs.concurrent
[error]     import play.api.libs.concurrent.execution.Implicits._
[error]                                                      ^
[error] /home/sas/tmp/ideas-ba/webservice/app/Global.scala:66: not found: value context
[error]     context.system.scheduler.schedule(
[error]     ^
[error] two errors found
[error] (compile:compile) Compilation failed
[error] Total time: 5 s, completed Nov 19, 2012 11:30:26 AM

I guess it's not "context" the way I should call it...

Julien Richard-Foy

unread,
Nov 19, 2012, 9:35:00 AM11/19/12
to play-fr...@googlegroups.com
See my answer, the right import is:

import play.api.libs.concurrent.Execution.Implicits.defaultContext

Regards,
Julien
> --
>
>

Pascal Voitot Dev

unread,
Nov 19, 2012, 9:34:58 AM11/19/12
to play-fr...@googlegroups.com
oups :D
Thks for remark


--



Yann Simon

unread,
Nov 19, 2012, 9:39:38 AM11/19/12
to play-fr...@googlegroups.com
Thx for pointing the new import.

2012/11/19 Pascal Voitot Dev <pascal.v...@gmail.com>
--
 
 

Sebastian Scarano

unread,
Nov 19, 2012, 9:56:12 AM11/19/12
to play-fr...@googlegroups.com
thanks for your help

I tried with the correct import and the compiler no longer complaints

but I dont know how to invoke the scheduler from the ExecutionContext (sorry, akka newbie here...)

--
 
 

sas

unread,
Nov 20, 2012, 7:56:37 AM11/20/12
to play-fr...@googlegroups.com
biesior summarized the needed changes in this SO answer

saludos

sas
Reply all
Reply to author
Forward
0 new messages