4

I'm trying to set up a simple play 2.5 application with slick and postgres, but can't seem to get past an error.
The error I'm getting is

[error] p.a.d.s.DefaultSlickApi - Failed to create Slick database config for key default.
slick.SlickException: Error getting instance of profile "slick.jdbc.PostgresProfile"
...
Caused by: java.lang.InstantiationException: slick.jdbc.PostgresProfile
...
Caused by: java.lang.NoSuchMethodException: slick.jdbc.PostgresProfile.<init>()
...

I've got the following in my application.conf

slick.dbs.default {
  driver = "slick.jdbc.PostgresProfile"
  db = {
    driver = "org.postgresql.Driver"

    user = postgres
    host = localhost
    port = 5432
    password = ""

    host = ${?EVENTUAL_DB_HOST}
    port = ${?EVENTUAL_DB_PORT}
    user = ${?EVENTUAL_DB_USER}
    password = ${?EVENTUAL_DB_PW}
    url = "jdbc:postgresql://"${slick.dbs.default.db.host}":"${slick.dbs.default.db.port}"/"${slick.dbs.default.db.user}
  }
}

and these in my dependencies

  "com.typesafe.play" %% "play-slick" % "2.1.0",
  "com.typesafe.slick" %% "slick-codegen" % "3.1.1",
  "com.github.tminglei" %% "slick-pg" % "0.15.0-RC", //"0.14.6",
  "org.postgresql" % "postgresql" % "42.0.0"

if I change slick.dbs.default.driver to slick.driver.PostgresDriver (which is now deprecated evidently) I get

[error] p.a.d.s.DefaultSlickApi - Failed to create Slick database config for key default.
slick.SlickException: Error getting instance of profile "slick.driver.PostgresDriver"
...
Caused by: java.lang.ClassNotFoundException: slick.driver.PostgresDriver
...

I'm about pulling my hair out here and can't find any other resources to look at. Does anyone have any idea what's going on?

kag0
  • 5,624
  • 7
  • 34
  • 67
  • Maybe `slick.dbs.default.driver="slick.driver.PostgresDriver$"` and not `Profile`? – insan-e Apr 13 '17 at 18:29
  • @insan-e sorry I had a typo there, I had tried `slick.driver.PostgresDriver` and I think I had tried `slick.driver.PostgresDriver$` as well with the same result, but let me try again just in case. – kag0 Apr 13 '17 at 18:31
  • @insan-e whelp, went back and tried with `slick.jdbc.PostgresProfile$` and now it works. If you want to submit an answer I'll accept it, otherwise I'll self answer a it later. – kag0 Apr 14 '17 at 15:26
  • I have a working example for play 2.5 + Slick + MySQL (yes, I know it's not Postgresql, but maybe you can find some problem comparing both. It shouldn't be very hard migration the example from MySQL to Postgresql): https://github.com/pedrorijo91/play-slick3-steps/tree/play2.5 (if you need a written tutorial, there's one at http://pedrorijo.com/blog/play-slick/) – pedrorijo91 Apr 14 '17 at 20:15

1 Answers1

8

Sure enough, by recommendation of insan-e, all I had to do was add a $. So slick.dbs.default.driver should be "slick.jdbc.PostgresProfile$".

kag0
  • 5,624
  • 7
  • 34
  • 67