I have just upgraded my application from play framework 2.3.9 to 2.4.6. Everything is working fine, but onstart(Application app) method getting executed twice. As i have created some scheduler in the onstart method, they are also getting executed twice.
Global.java
public class Global extends GlobalSettings {
public void onStart(Application app) {
Logger.info("Application has started");
JPA.withTransaction(() -> {
if (ConfigHelper.getGlobalValue("install").equalsIgnoreCase("xyz")) {
Logger.info("Starting pqr scheduler");
ActorRef myActor = Akka.system().actorOf(
Props.create(PQR.class));
FiniteDuration delay = FiniteDuration.create(0, TimeUnit.SECONDS);
FiniteDuration frequency = FiniteDuration.create(10, TimeUnit.MINUTES);
Akka.system()
.scheduler()
.schedule(delay, frequency, myActor, "start", Akka.system().dispatcher(), myActor);
}
});
}
public void onStop(Application app) {
Logger.info("Application shutdown...");
}
}
plugin.sbt file is as below
logLevel := Level.Warn
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.6")
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "2.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.1")
addSbtPlugin("net.ground5hark.sbt" % "sbt-css-compress" % "0.1.3")
addSbtPlugin("net.ground5hark.sbt" % "sbt-closure" % "0.1.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")
build.sbt is as below:
name := "project name"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
javaJdbc, javaJpa, cache, javaWs,
"org.hibernate" % "hibernate-entitymanager" % "4.3.9.Final",
"mysql" % "mysql-connector-java" % "5.1.35",
"com.amazonaws" % "aws-java-sdk-ses" % "1.9.38",
"com.amazonaws" % "aws-java-sdk-s3" % "1.9.38",
"org.freemarker" % "freemarker" % "2.3.22"
)
resolvers += "Sonatype" at "url"
credentials += Credentials("Repository Manager", "***", "***", "****")
Note: I am using jpa in the project. Any help would be highly appreciated.