Reputation: 97727
I'm trying to learn Play, Scala, and Guice at the moment and I'm having an issue with version 2.3.7 of Play. When I launch the example by changing the plugins.sbt's Play version to 2.3.6 the app's ApplicationController loads normally. However when switch to 2.3.7 in plugins.sbt, I just get an empty page.
I combined the Play-Guice example (which is built with an earlier version Play) with the Slick data access example.
Here's my Application.scala play controller code without package and import:
@Singleton
class Application @Inject() (textGenerator: TextGenerator) extends Controller {
def index = Action {
Ok(views.html.index(textGenerator.welcomeText))
}
}
object Application extends Controller {
def index = Action {
Ok(views.html.index("Your new application is ready.", "Home"))
}
}
Here's my Global.scala (minus import):
object Global extends GlobalSettings {
/**
* Bind types such that whenever TextGenerator is required, an instance of WelcomeTextGenerator will be used.
*/
val injector = Guice.createInjector(new AbstractModule {
protected def configure() {
bind(classOf[TextGenerator]).to(classOf[WelcomeTextGenerator])
}
})
/**
* Controllers must be resolved through the application context. There is a special method of GlobalSettings
* that we can override to resolve a given controller. This resolution is required by the Play router.
*/
override def getControllerInstance[A](controllerClass: Class[A]): A = injector.getInstance(controllerClass)
}
Can anyone see why one version of Play would work, but not the other?
Any requests for information or educated guesses are welcome too!
Note: So far there's no apparent error message, the only difference I have seen between the two versions is one loads the page and the other does not. No known logged errors, error messages, or code differences (other than the version switch, of course).
Build.scala (minus imports):
object ApplicationBuild extends Build {
val appName = "root"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
"com.google.inject" % "guice" % "3.0",
"javax.inject" % "javax.inject" % "1",
"org.mockito" % "mockito-core" % "1.9.5" % "test"
)
val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings(
version := appVersion,
libraryDependencies ++= appDependencies
)
}
Upvotes: 0
Views: 232
Reputation: 97727
Later I went back and tried to switch back to 2.3.7 as @akkie suggested, and the website was able to launch and work normally.
Going backwards over what changed there seems to be two likely possibilities that caused the website to fail.
Either
Bear in mind that these are just guesses, so I may have missed some other change that helped fix the issue. Nonetheless I figure I or someone else might be helped by reading my notes on getting it to work later.
Upvotes: 0