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?

4
  • Maybe slick.dbs.default.driver="slick.driver.PostgresDriver$" and not Profile? Commented Apr 13, 2017 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. Commented Apr 13, 2017 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. Commented Apr 14, 2017 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): github.com/pedrorijo91/play-slick3-steps/tree/play2.5 (if you need a written tutorial, there's one at pedrorijo.com/blog/play-slick) Commented Apr 14, 2017 at 20:15

1 Answer 1

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$".

Sign up to request clarification or add additional context in comments.

3 Comments

what that $ means in this context? why its needed?
@freakman it has do to do with compiled class names, see something like stackoverflow.com/questions/11388840/…
but its strange in some places you need to pass full class name with $ and in other ones without it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.