0
votes

After upgrading to 2.5 version of Play I'm facing this problem when I try to run project in production mode. It seems like in this version I need to initialize pool manually ScalikeJDBC: Connection pool is not yet initialized.(name:'default) I can't understand how can I do this. I've added this class:

import play.api.Logger
import scalikejdbc._
import scalikejdbc.config._

class DbInitializer {
    DBs.setupAll()
    Logger.debug("DB initialized")
}

and in my module mark it as EagerSingleton:

class GlobalModule extends AbstractModule {
  def configure() = {
    bind(classOf[DbInitializer]).asEagerSingleton()
  }
}

Now when I run my project in production I see:

[info] application - Creating Pool for datasource 'default' [info] p.a.d.DefaultDBApi - Database [default] connected at jdbc:postgresql://localhost:5432/inetshop [debug] application - [debug] application - DB initialized Oops, cannot start the server. com.google.inject.CreationException: Unable to create injector, see the following errors:

1) Error injecting constructor, java.lang.IllegalStateException: Connection pool is not yet initialized.(name:'default) at controllers.Application.(Application.scala:20)

So my Initializer run successfully but still facing this problem. Need help to fix this.

1
What DBs.setupAll() does?marcospereira
Here scalikejdbc.org/documentation/… they said: "After just calling scalikejdbc.config.DBs.setupAll(), Connection pools are prepared."sergeda

1 Answers

0
votes

I've had a similar problem, (Connection pools settings were ignored) not exactly the same, but maybe it helps:

we had to enable the scalikejdbc-play-dbapi-adapter: build.sbt: "org.scalikejdbc" %% "scalikejdbc-play-dbapi-adapter" %

and add to application.conf: play.modules.enabled += "scalikejdbc.PlayDBApiAdapterModule"