[play 2.4.0-RC5 Scala] evolutions and injector error with play-slick

1,983 views
Skip to first unread message

Alejandro Pedraza

unread,
May 19, 2015, 10:12:48 AM5/19/15
to play-fr...@googlegroups.com
Hi,

I'm getting this at runtime:

play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors:


1) A binding to play.api.db.DBApi was already configured at play.api.db.slick.evolutions.EvolutionsModule.bindings(EvolutionsModule.scala:14):
Binding(interface play.api.db.DBApi to ConstructionTarget(class play.api.db.slick.evolutions.internal.DBApiAdapter) in interface javax.inject.Singleton) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1).
  at play
.api.db.DBModule.bindings(DBModule.scala:25):
Binding(interface play.api.db.DBApi to ProviderConstructionTarget(class play.api.db.DBApiProvider)) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)


Is it because I'm using jdbc/anorm + play-slick + play-slick-evolutions dependencies at the same time? I'm transitioning to Slick from Anorm, but it's a large codebase so not doing it all at once...

Here's the relevant part of build.sbt:

libraryDependencies ++= Seq(
  jdbc
, ws,
 
"com.typesafe.slick" %% "slick-codegen" % "3.0.0",
 
"com.typesafe.play" %% "anorm" % "2.4.0-RC3",
 
"com.typesafe.play" %% "play-slick" % "1.0.0-RC3",
 
"com.typesafe.play" %% "play-slick-evolutions" % "1.0.0-RC3",
 
"mysql" % "mysql-connector-java" % "5.1.18",


Thanks in advance,
Alejandro

Mirco Dotta

unread,
May 19, 2015, 11:03:48 AM5/19/15
to play-fr...@googlegroups.com
Hi Alejandro,

Indeed, you can’t have both jdbc and play-slick  in your project’s dependencies. See https://www.playframework.com/documentation/2.4.x/PlaySlickFAQ#A-binding-to-play.api.db.DBApi-was-already-configured The issue is that both components need to bind the play.api.db.DbApi.

Not sure if it helps, but while migrating you can turn-off the play.api.db.slick.SlickModule, which is responsible for wiring Slick to Play DBApi. To do so, add the following in your application.conf

play.modules.disabled += “play.api.db.slick.SlickModule"

However, this means that you will get an exception the moment you are calling a controller that needs to access the database via Slick.

Of course, it’s also possible to disable the jdbc class responsible for wiring DBApi, the class is play.api.db.DBModule.

Maybe, selectively disabling the module that you don’t want to use will ease the migration.

Cheers,
Mirco
----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages