Question

I try to migrate a Java play framework project from play 2.1.1. to 2.2.0. I followed the migration guide (https://www.playframework.com/documentation/2.2.0/Migration22) but get following compilation error after applying the changes:

.../Global.java:38: cannot find symbol
symbol  : method schedule(scala.concurrent.duration.FiniteDuration,
              scala.concurrent.duration.FiniteDuration,akka.actor.ActorRef,
              parser.ParserActor.MensaName,scala.concurrent.ExecutionContext)
location: interface akka.actor.Scheduler
                .schedule(Duration.create(diff, TimeUnit.MILLISECONDS),
                ^
.../controllers/Parsers.java:24: cannot find symbol
symbol  : method scheduleOnce(scala.concurrent.duration.FiniteDuration,akka.actor.ActorRef,parser.ParserActor.MensaName,scala.concurrent.ExecutionContext)
location: interface akka.actor.Scheduler
                .scheduleOnce(Duration.create(0, TimeUnit.SECONDS),
                ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
(compile:compile) javac returned nonzero exit code

I tried to compile it with typesafe-activator and the play command, both does not work. The compilation works with both tools when I am using the old play version.

I guess that I am missing a dependency some where. E.g. do I have to add Akka manually to the dependencies since the new version? Or did I oversee some other common mistake?

plugins.sbt

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0")

build.properties

sbt.version=0.13.0

Build.scala

    import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {

  val appName         = "mensa-server"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    // Add your project dependencies here,
    javaCore,
    javaJdbc,
    javaEbean,
    "org.jsoup" % "jsoup" % "1.7.2",
    "net.sf.flexjson" % "flexjson" % "3.0",
    "postgresql" % "postgresql" % "9.1-901.jdbc4",
    "org.apache.commons" % "commons-lang3" % "3.1",
    "com.typesafe" %% "play-plugins-mailer" % "2.1.0",
    "org.apache.pdfbox" % "pdfbox" % "1.8.2"
  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    // Add your own project settings here      
  )
}
Was it helpful?

Solution

Akka version changed in Play 2.2 so you have to make some adjustments.

I don't have your java code, so I'm going to use my code to help you (I'm currently doing a migration as well). If my anwser doesn't resolve your issue, please add your java code.

For both scheduler and scheduleOnce, with this new version, you have to add an ExecutionContext, you can do Akka.system().dispatcher() as parameter

For example, before:

Akka.system().scheduler()
             .scheduleOnce(Duration.create(1, TimeUnit.SECONDS),
                 new Runnable() {
                     @Override
                     public void run() {
                         video.process(action);
                     }
                 });

After :

Akka.system().scheduler()
             .scheduleOnce(Duration.create(1, TimeUnit.SECONDS),
                 new Runnable() {
                     @Override
                     public void run() {
                         video.process(action);
                     }
                 }, 
                 Akka.system().dispatcher());

If you want more information : http://www.playframework.com/documentation/2.2.x/JavaAkka

I'm not sure this is going to help you, but that's the only change I had to do to migrate successfully schedulers in 2.2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top