[Play 2.4.0-RC1] [Play-slick 1.0.0] A binding to play.api.db.DBApi was already configured ...

1,055 views
Skip to first unread message

Johan Dahlberg

unread,
May 2, 2015, 5:34:16 PM5/2/15
to play-fr...@googlegroups.com
I am trying to implement this example but I get the following error:


1) A binding to play.api.db.DBApi was already configured at play.api.db.slick.SlickModule.bindings(SlickModule.scala:42):
Binding(interface play.api.db.DBApi to ConstructionTarget(class play.api.db.slick.internal.DBApiAdapter) in interface javax.inject.Singleton).
 at play
.api.db.DBModule.bindings(DBModule.scala:25):
Binding(interface play.api.db.DBApi to ProviderConstructionTarget(class play.api.db.DBApiProvider))

Is this a common problem? I don't really get what is causing it.

Hossein Kazemi

unread,
May 3, 2015, 7:53:23 AM5/3/15
to play-fr...@googlegroups.com
Hi, Is Play-slick 1.0.0-RC1 released or made a local build?

Johan Dahlberg

unread,
May 3, 2015, 8:54:01 AM5/3/15
to play-fr...@googlegroups.com

I published it locally since I couldn't find a release of it.

/Johan


--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/NOFbfx13fio/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hossein Kazemi

unread,
May 3, 2015, 9:24:46 AM5/3/15
to play-framework
Thanks! I am also trying to do so, but I get this error:

[warn] Multiple resolvers having different access mechanism configured with same name 'typesafe-releases'. To avoid conflict, Remove duplicate project resolvers (`resolvers`) or rename publishing resolver (`publishTo`).
java.lang.ClassCastException: Cannot cast com.typesafe.sbt.SbtPgp$ to sbt.AutoPlugin
at java.lang.Class.cast(Class.java:3356)
at sbt.ModuleUtilities$.getCheckedObject(ModuleUtilities.scala:20)

Did you have it also? or do u know why this happens?

Johan Dahlberg

unread,
May 3, 2015, 2:16:57 PM5/3/15
to play-fr...@googlegroups.com
I haven't seen that error but how does your build.sbt and plugins.sbt look like? You probably have the same resolver specified twice.

/Johan

Hossein Kazemi

unread,
May 4, 2015, 2:16:23 AM5/4/15
to play-framework
Deleting the .sbt folder helped me.

Mirco Dotta

unread,
May 4, 2015, 5:42:59 AM5/4/15
to play-fr...@googlegroups.com
Hi Johan,

First of all, thanks a lot for trying it out. Really appreciate the feedback.

The error you are getting seems to indicate that the Play interface DBApi is being bound a second time. However, the stacktrace does’t show what module is trying to bind DBApi the second time.

My first reaction was: is it possible that you have added “jdbc” to your libraryDependencies in your sbt build? If so, please remove it (or let me know why you need it, as I’m assuming you don’t). If that’s isn’t what’s happening, can you upload your project somewhere so that I can take a look.

Thanks,
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.

Johan Dahlberg

unread,
May 4, 2015, 5:48:50 AM5/4/15
to play-fr...@googlegroups.com
@Mirco: 
I have made a small project with the error that you can find here;
https://github.com/johdah/MyEconomy

/Johan

You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/NOFbfx13fio/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.

Mirco Dotta

unread,
May 4, 2015, 6:29:02 AM5/4/15
to play-fr...@googlegroups.com
Joahn,

In your build.sbt, if you change the version of play-slick to "1.0.0-2015-05-03-a1c424e-SNAPSHOT”, it should work (it did for me). I’ve just pushed a PR against your project https://github.com/johdah/MyEconomy/pull/1

Why publishing play-slick locally produces the error you have seen is beyond me at the moment. I’ll keep digging, but the above is a quick workaround that should be good enough for the moment.

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

Typesafe – Build reactive apps!

Mirco Dotta

unread,
May 5, 2015, 12:22:23 PM5/5/15
to play-fr...@googlegroups.com
The underlying problem was identified and a fix is on the way. You can follow development about this issue here https://github.com/playframework/play-slick/issues/245

----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

Hossein Kazemi

unread,
May 6, 2015, 1:32:24 AM5/6/15
to play-fr...@googlegroups.com
@Mirco:
Could you tell me what the differences are between RelationalProfile and JdbcProfile in slick? I see them used interchangeably in the play-slick samples but I can't find any proper documentation about where to use what.
Also, "1.0.0-2015-05-03-a1c424e-SNAPSHOT” pulls in the 2.4.0-SNAPSHOT in my project. Is there a dependency that works with 2.4.0-RC1 ?
Thanks

Johan Dahlberg

unread,
May 6, 2015, 1:58:18 AM5/6/15
to play-fr...@googlegroups.com
Nice, i will follow that issue. Thx!

/Johan

Naftoli Gugenheim

unread,
May 7, 2015, 3:10:09 PM5/7/15
to play-fr...@googlegroups.com

JdbcProfile extends RelationalProfile and adds things that are specific to the jdbc implementation. So if you wanted to make an implementation for the async Postgres project, you would have to extend RelationalProfile and implement everything abstract, differently than JdbcProfile.

Mirco Dotta

unread,
May 10, 2015, 4:39:31 AM5/10/15
to play-fr...@googlegroups.com
Hi Hossein,

Sorry, I’ve been away for a few days and didn’t have an opportunity to follow up on this one.

As a general rule, I would say use a RelationalProfile if you can. As you will notice, for executing some db actions a RelationalProfile won't be enough (you will get a compilation error), and that’s when you should use the more specific JdbcProfile (JdbcProfile is a subtype of RelationalProfile). An example is calling Query.update.

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

Typesafe – Build reactive apps!

Hossein Kazemi

unread,
May 10, 2015, 12:01:37 PM5/10/15
to play-framework
Hi Mirco, Thanks a lot for the explanation. I just Upgraded my play app to RC2 and my play-slick to RC1(I was using a snapshot version you mentioned). However, on startup I get this error (I have clean my ivy cache btw):

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.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).
  at play.api.db.slick.SlickModule.bindings(SlickModule.scala:42):
Binding(interface play.api.db.DBApi to ConstructionTarget(class play.api.db.slick.internal.DBApiAdapter) in interface javax.inject.Singleton) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)

1 error]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:165) ~[play-server_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:121) ~[play-server_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at scala.Option.map(Option.scala:146) ~[scala-library-2.11.6.jar:na]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:121) ~[play-server_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:119) ~[play-server_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at scala.util.Success.flatMap(Try.scala:230) ~[scala-library-2.11.6.jar:na]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:119) ~[play-server_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:111) ~[play-server_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) ~[scala-library-2.11.6.jar:na]
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[scala-library-2.11.6.jar:na]
        at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423) ~[na:1.8.0_20]
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[na:1.8.0_20]
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:902) ~[na:1.8.0_20]
        at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1689) ~[na:1.8.0_20]
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1644) ~[na:1.8.0_20]
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[na:1.8.0_20]
Caused by: com.google.inject.CreationException: Unable to create injector, see the following errors:

1) A binding to play.api.db.DBApi was already configured 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).
  at play.api.db.slick.SlickModule.bindings(SlickModule.scala:42):
Binding(interface play.api.db.DBApi to ConstructionTarget(class play.api.db.slick.internal.DBApiAdapter) in interface javax.inject.Singleton) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)

1 error
        at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:466) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107) ~[guice-4.0.jar:na]
        at com.google.inject.Guice.createInjector(Guice.java:96) ~[guice-4.0.jar:na]
        at com.google.inject.Guice.createInjector(Guice.java:73) ~[guice-4.0.jar:na]
        at com.google.inject.Guice.createInjector(Guice.java:62) ~[guice-4.0.jar:na]
        at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126) ~[play_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) ~[play_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21) ~[play_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:153) ~[play-server_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:150) ~[play-server_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:150) ~[play-server_2.11-2.4.0-RC2.jar:2.4.0-RC2]
        ... 15 common frames omitted
2015-05-10 17:57:59 +0200 [ERROR] from application in New I/O worker #1 - 

Could you  please have a look at it?
Thanks
Hossein

Mirco Dotta

unread,
May 10, 2015, 2:25:05 PM5/10/15
to play-fr...@googlegroups.com
Hi Hossein,

Check if you have jdbc in your build's libraryDependencies (and remove it if so). If you don’t, then you are likely experiencing the same problem reported by Johan (see ticket https://github.com/playframework/play-slick/issues/245). There may be ways to workaround the problem, but considering a fix is on its way, I suggest to wait until a play-slick 1.0-RC2 is available. I’ll let you know the moment it’s published.

Really appreciate the feedback. Keep it coming! :-)

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

Typesafe – Build reactive apps!

Hossein Kazemi

unread,
May 11, 2015, 5:00:49 AM5/11/15
to play-framework
Hi Mirco,
I don't have the jdbc in my build.sbt. So it seems the same problem as Johan. I switched backed to the SNAPSHOT version for now. The only problem with that is that it also pulls in a snapshot version of play, even if I have set my play version to RC1.
Cheers,
Hossein

Mirco Dotta

unread,
May 11, 2015, 6:41:54 AM5/11/15
to play-fr...@googlegroups.com
I guess you are getting a SNAPSHOT because SNAPSHOT > RC, so the dependency on RC gets evicted in favour of SNAPSHOT.

There is PR ready to merge in play-slick that fixes the issue https://github.com/playframework/play-slick/pull/247

The moment we have a Play 2.4.0-RC3 release, we will also publish a play-slick 1.0.0-RC2.

— Mirco

----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

Mirco Dotta

unread,
May 15, 2015, 3:00:26 AM5/15/15
to play-fr...@googlegroups.com
play-slick 1.0.0-RC2 was released (mind that it depends on Play 2.4.0-RC3).

Please, upgrade and let me know if you hit any issue (the DBApi binding exception should not happen anymore)

And, as usual, any feedback you may have is highly appreciated.

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

Typesafe – Build reactive apps!

Julien L.

unread,
May 15, 2015, 8:25:20 AM5/15/15
to play-fr...@googlegroups.com
Hello !

I used to have the same problem, solved by migrating to 1.0.0-RC2 (with Play 2.4.0-RC3). 

Thanks!

Mirco Dotta

unread,
May 15, 2015, 8:35:50 AM5/15/15
to play-fr...@googlegroups.com
Awesome! Thanks for confirming it’s all good now.
----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

Jari Pennanen

unread,
Jun 19, 2015, 1:13:26 PM6/19/15
to play-fr...@googlegroups.com
Hello!

Just got hit by this.

On Monday, May 4, 2015 at 12:42:59 PM UTC+3, Mirco Dotta wrote:
Hi Johan,

My first reaction was: is it possible that you have added “jdbc” to your libraryDependencies in your sbt build? If so, please remove it (or let me know why you need it, as I’m assuming you don’t). 

Problem is that Play Framework adds the jdbc by default to the libraryDependencies if you run "activator new MyProject play-scala":

This is the vanilla libraryDependencies created by Play Framework:

`
libraryDependencies ++= Seq(
  jdbc,
  cache,
  ws,
  specs2 % Test
)
`

Play-Slick documentation https://www.playframework.com/documentation/2.4.x/PlaySlick should say that this needs to be removed before using, I had to google the error and found myself to this thread.

Thanks.

Patrick Kelly

unread,
Aug 6, 2015, 2:54:20 PM8/6/15
to play-framework
I got hit by this as well.  Removing "jdbc" resolved the issue.

Henrique Ferrolho

unread,
Oct 4, 2015, 2:25:38 PM10/4/15
to play-framework
Hey! I am having the same problem... but removing jdbc doesn't seem to solve the problem.

Here is my build.sbt:

name := """lyrics-mini-app"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  "com.typesafe.play" %% "play-slick" % "1.0.1",
  "com.typesafe.play" %% "play-slick-evolutions" % "1.0.1",
  "com.h2database" % "h2" % "1.4.189",
  specs2 % Test
  //jdbc,
  //cache,
  //ws
)

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

Henrique Ferrolho

unread,
Oct 5, 2015, 4:33:04 AM10/5/15
to play-framework
Ok, somehow this started working today... As soon as I ran 'activator run' - play asked me if I wanted to apply the database script - which I did and it worked. I guess rebooting the computer did the trick. Anyway, I would like to hear you guys about this since I am starting with play... why did a reboot solve the problem? Was it a bad server running in the background somehow? Or what I needed was to reset the database? - is there even a command for that?

I have used Laravel recently and I find it very practical regarding the database management - all I needed to do in order to reset it was run 'php artisan migrate:refresh'

Thank you!
Reply all
Reply to author
Forward
0 new messages