[2.4][Slick] slick.dbs.default.db.driver seems to be ignored

56 visualizzazioni
Passa al primo messaggio da leggere

descsuit

da leggere,
26 lug 2016, 17:23:2926/07/16
a play-framework
I'm getting an error saying that Play can't provision the DbConfigProvider due to a NullPointerException.  When I look at the code it seems that the driver is what's null.  If I comment out the line in my application.conf that has the mysql driver (slick.dbs.default.db.driver) I get the same error, so I can't help but think there's something wrong there. The error:
Error injecting constructor, java.lang.NullPointerException
  at dao.UserDAO.<init>(UserDAO.scala:19)
  at dao.UserDAO.class(UserDAO.scala:19)
  while locating dao.UserDAO
    for parameter 2 at controllers.StudentSetApp.<init>(StudentSetApp.scala:34)
  at controllers.StudentSetApp.class(StudentSetApp.scala:34)
  while locating controllers.StudentSetApp
    for parameter 14 at router.Routes.<init>(Routes.scala:83)
  while locating router.Routes
  while locating play.api.inject.RoutesProvider
  while locating play.api.routing.Router
Caused by: java.lang.NullPointerException
at play.api.db.slick.HasDatabaseConfig$class.driver(DatabaseConfigProvider.scala:142)
at dao.UserDAO.driver$lzycompute(UserDAO.scala:19)
at dao.UserDAO.driver(UserDAO.scala:19)...

Do I have to do something special for mysql, like we used to do to load the driver or is that handled by Play? Here's the relevant part of my application.conf:

slick.dbs {

  default.driver="slick.driver.MySQLDriver$"

  default.db.url="jdbc:mysql://localhost/diagnoser_results"

  default.db.driver="com.mysql.jdbc.Driver"

  default.db.user=xxx

  default.db.pass=xxx

}


My build.sbt has the following in it's library dependencies:

"com.typesafe.play" %% "play-slick" % "1.1.1",

"com.typesafe.play" %% "play-slick-evolutions" % "1.1.1",

"mysql" % "mysql-connector-java" % "5.1.35",


Any idea what I'm missing?

Alan

descsuit

da leggere,
29 lug 2016, 18:30:1329/07/16
a play-framework
Solved.  It turns out I had a member variable that was a mapped column type that wasn't lazy loaded.  That caused scala to access the dbConfig before it was prepped.

Alan
Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi