slick-pg icon indicating copy to clipboard operation
slick-pg copied to clipboard

usage with play-slick causes classloader issues (Play 2.4)

Open dvic opened this issue 9 years ago • 24 comments

I cannot run my Play project with run, I have to use start or testProd. When I use run, I get:

Caused by: slick.SlickException: Error getting instance of Slick driver "dao.ExtendedPgDriver$"
        at slick.backend.DatabaseConfig$.forConfig(DatabaseConfig.scala:60) ~[slick_2.11-3.0.0.jar:na]
        at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.create(SlickApi.scala:89) ~[play-slick_2.11-1.0.0.jar:1.0.0]
        ... 59 common frames omitted
Caused by: java.lang.ClassNotFoundException: dao.ExtendedPgDriver$
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_45]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_45]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_45]
        at java.lang.Class.forName0(Native Method) ~[na:1.8.0_45]
        at java.lang.Class.forName(Class.java:264) ~[na:1.8.0_45]
        at slick.backend.DatabaseConfig$.forConfig(DatabaseConfig.scala:57) ~[slick_2.11-3.0.0.jar:na]
        ... 60 common frames omitted

I also asked about this on the play framework mailing list: https://groups.google.com/d/msg/play-framework/KH0_oDFA4eY/3-lI9sH_iVsJ

Any idea if this can be fixed? Maybe you can update the examples to Play 2.4 with play-slick if you have time, so people can use that as a reference.

Thanks!

dvic avatar Jun 03 '15 19:06 dvic

I have a workaround: use hardcoded import dao.ExtendedPgDriver.api._ in the DAO, instead of import driver.api._ (which is the usual way of working with play-slick). This also means that I have to set the driver to slick.driver.PostgresDriver (however, it's not used because I don't import driver.api._)

I'm curious: is this the only way to get the implicits to work? I mean import driver.api._ would never work right (because that generic JdbcProfile driver interface would miss all the extra pg stuff)?

dvic avatar Jun 03 '15 19:06 dvic

Ok, I'll update the example asap.

tminglei avatar Jun 03 '15 23:06 tminglei

I had the same problem as well, and reading around a bit, it seems that Play has a complex classloader setup (8 different class loaders as of right now) when running in "dev" mode, so they can do their hot reloading on code changes. The issue is that the different classloaders are responsible for different groups of modules - the Play dependencies (including play-slick) are handled by one, and the classes in your Play app, including the custom Postgres driver are located in another. My Java/Play kung-fu is not good enough to understand the fine details of how these classloaders interact, but basically the classloader used for Play Slick can't "see" the custom driver under the classloader for your application code. Whether this is intentional or a bug in the Play classloader, I'm not sure.

After some reading and experimentation, it seems that the problem only affects loading the custom driver class from your application code, and not from external dependencies. My workaround was to create a new SBT project that contains only the custom Postgres driver, publish it locally, and include it in my Play project as an external dependency.

While it's less hacky then loading methods from a different driver class in my DAOs like @damirv did, it's also a bit unwieldy, so I'm not proud of it...

I'd be very interested to see if you can find a more elegant solution, maybe getting the Play classloader to somehow recognise the custom driver class in dev mode.

motns avatar Jun 04 '15 12:06 motns

Updated play-slick example project, but it seems it won't compile scala files under dir '/app', and complains as below:

[play-slick-pg] $ compile
[info] Updating {file:/media/workspace/repos/slick-pg/examples/play-slick-example/}root...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 17 Scala sources and 1 Java source to /media/workspace/repos/slick-pg/examples/play-slick-example/target/scala-2.11/classes...
[error] /media/workspace/repos/slick-pg/examples/play-slick-example/conf/routes:6: type Application is not a member of package controllers
[error] GET     /                           controllers.Application.index
[error] /media/workspace/repos/slick-pg/examples/play-slick-example/conf/routes:6: type Application is not a member of package controllers
[error] GET     /                           controllers.Application.index
[error] /media/workspace/repos/slick-pg/examples/play-slick-example/conf/routes:6: type Application is not a member of package controllers
[error] GET     /                           controllers.Application.index
[error] three errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 18 s, completed Jun 13, 2015 8:29:22 PM

So strange.

tminglei avatar Jun 13 '15 12:06 tminglei

I'll see if I can fix this, also implementing the example project with the new dependency injection constructs from Play 2.4.

On Saturday, June 13, 2015, 涂名雷 [email protected] wrote:

Updated play-slick example project, but it seems it won't compile scala files under dir '/app', and complains as below:

[play-slick-pg] $ compile [info] Updating {file:/media/workspace/repos/slick-pg/examples/play-slick-example/}root... [info] Resolving jline#jline;2.12.1 ... [info] Done updating. [info] Compiling 17 Scala sources and 1 Java source to /media/workspace/repos/slick-pg/examples/play-slick-example/target/scala-2.11/classes... [error] /media/workspace/repos/slick-pg/examples/play-slick-example/conf/routes:6: type Application is not a member of package controllers [error] GET / controllers.Application.index [error] /media/workspace/repos/slick-pg/examples/play-slick-example/conf/routes:6: type Application is not a member of package controllers [error] GET / controllers.Application.index [error] /media/workspace/repos/slick-pg/examples/play-slick-example/conf/routes:6: type Application is not a member of package controllers [error] GET / controllers.Application.index [error] three errors found error Compilation failed [error] Total time: 18 s, completed Jun 13, 2015 8:29:22 PM

So strange.

— Reply to this email directly or view it on GitHub https://github.com/tminglei/slick-pg/issues/163#issuecomment-111708723.

Kind regards,

Damir Vandic | Ontostream

dvic avatar Jun 14 '15 08:06 dvic

Made a PR that fixes this issue (#169).

dvic avatar Jun 14 '15 10:06 dvic

@damirv merged, thank you! :+1:

tminglei avatar Jun 15 '15 04:06 tminglei

Slick 3.1-M1 has a fix for this issue - https://github.com/slick/slick/commit/4565f09fef915b24d2155f5173d0f8053c3ac614

Can we have a slick-pg version out to try this.

ghost avatar Jul 21 '15 17:07 ghost

Released slick-pg 0.10.0-M1, pls check it. Thanks!

tminglei avatar Jul 21 '15 23:07 tminglei

I just checked: it works with the 1.1.x branch of play-slick :+1: (had to manually publish it locally so that it uses slick 3.1-M1).

dvic avatar Jul 22 '15 10:07 dvic

I'm still having issues with this. I pulled down the 1.1.x branch of play-slick and master on slick-pg, built and published both projects locally and started using them from my project. However, I still have to do sbt start instead of sbt run in order to make all of this work. Doing sbt run still results in the aforementioned ClassNotFoundException. Any thoughts on how I can resolve this?

EDIT: It's worth noting that I've simply moved my custom driver class out to a separate project as others have done, but this is less than optimal.

enragedginger avatar Jul 25 '15 00:07 enragedginger

Hmm.. for me it worked. Can you replicate it in a dummy project you can post on Github?

dvic avatar Jul 25 '15 10:07 dvic

I can confirm that this works for me (after i did a local publish of play-slick and used 0.10.0-M1 of slick-pg

ghost avatar Jul 27 '15 10:07 ghost

@damirv, for some reason I still can't make this work. Here's what I did:

  1. Cloned the sample project
  2. Commented out play-slick dependency in build.sbt
  3. Updated the slick-pg version to 0.10.0-M1
  4. Cloned play-slick repo and ran sbt publish-local on the 1.1.x branch.
  5. Copied play-slick_2.10.jar and play-slick-evolutions_2.10.jar to the lib folder in the root of the project
  6. Updated my slick.dbs.default.db.url in application.conf to my local postgres instance
  7. Deleted all the tests (they caused some compilation errors that are not important here)
  8. Compiled and ran the project with sbt run.

The server started fine, but whenever I open localhost:9000, I get the following runtime error:

play.api.UnexpectedException: Unexpected exception[NoClassDefFoundError: play/db/NamedDatabaseImpl]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:169) ~[play-server_2.11.jar:2.4.0]
        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.jar:2.4.0]
        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.jar:2.4.0]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:119) ~[play-server_2.11.jar:2.4.0]
        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.jar:2.4.0]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:111) ~[play-server_2.11.jar:2.4.0]
        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:1402) ~[na:1.8.0_40]
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[na:1.8.0_40]
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[na:1.8.0_40]
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689) ~[na:1.8.0_40]
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[na:1.8.0_40]
Caused by: java.lang.NoClassDefFoundError: play/db/NamedDatabaseImpl
        at play.api.db.slick.SlickModule.bindNamed(SlickModule.scala:51) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at play.api.db.slick.SlickModule$$anonfun$namedDatabaseConfigBindings$1.apply(SlickModule.scala:44) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at play.api.db.slick.SlickModule$$anonfun$namedDatabaseConfigBindings$1.apply(SlickModule.scala:43) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at scala.collection.immutable.List.map(List.scala:273) ~[scala-library-2.11.6.jar:na]
        at play.api.db.slick.SlickModule.namedDatabaseConfigBindings(SlickModule.scala:43) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at play.api.db.slick.SlickModule.bindings(SlickModule.scala:40) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at play.api.db.slick.SlickModule.bindings(SlickModule.scala:32) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at play.api.inject.guice.GuiceableModuleConversions$class.guice(GuiceInjectorBuilder.scala:264) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceableModule$.guice(GuiceInjectorBuilder.scala:200) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceableModuleConversions$$anon$3$$anonfun$guiced$2.apply(GuiceInjectorBuilder.scala:244) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceableModuleConversions$$anon$3$$anonfun$guiced$2.apply(GuiceInjectorBuilder.scala:244) ~[play_2.11-2.4.2.jar:2.4.2]
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245) ~[scala-library-2.11.6.jar:na]
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245) ~[scala-library-2.11.6.jar:na]
        at scala.collection.immutable.List.foreach(List.scala:381) ~[scala-library-2.11.6.jar:na]
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:245) ~[scala-library-2.11.6.jar:na]
        at scala.collection.immutable.List.map(List.scala:285) ~[scala-library-2.11.6.jar:na]
        at play.api.inject.guice.GuiceableModuleConversions$$anon$3.guiced(GuiceInjectorBuilder.scala:244) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceableModule$$anonfun$guiced$1.apply(GuiceInjectorBuilder.scala:222) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceableModule$$anonfun$guiced$1.apply(GuiceInjectorBuilder.scala:222) ~[play_2.11-2.4.2.jar:2.4.2]
        at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:252) ~[scala-library-2.11.6.jar:na]
        at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:252) ~[scala-library-2.11.6.jar:na]
        at scala.collection.immutable.List.foreach(List.scala:381) ~[scala-library-2.11.6.jar:na]
        at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:252) ~[scala-library-2.11.6.jar:na]
        at scala.collection.immutable.List.flatMap(List.scala:344) ~[scala-library-2.11.6.jar:na]
        at play.api.inject.guice.GuiceableModule$.guiced(GuiceInjectorBuilder.scala:222) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceBuilder.createModule(GuiceInjectorBuilder.scala:116) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceApplicationBuilder.applicationModule(GuiceApplicationBuilder.scala:87) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21) ~[play_2.11-2.4.2.jar:2.4.2]
        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.jar:2.4.0]
        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.jar:2.4.0]
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.4.2.jar:2.4.2]
        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.jar:2.4.0]
        ... 14 common frames omitted
Caused by: java.lang.ClassNotFoundException: play.db.NamedDatabaseImpl
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_40]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_40]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_40]
        ... 48 common frames omitted

play.api.UnexpectedException: Unexpected exception[NoClassDefFoundError: play/db/NamedDatabaseImpl]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:169) ~[play-server_2.11.jar:2.4.0]
        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.jar:2.4.0]
        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.jar:2.4.0]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:119) ~[play-server_2.11.jar:2.4.0]
        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.jar:2.4.0]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:111) ~[play-server_2.11.jar:2.4.0]
        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:1402) ~[na:1.8.0_40]
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[na:1.8.0_40]
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[na:1.8.0_40]
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689) ~[na:1.8.0_40]
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[na:1.8.0_40]
Caused by: java.lang.NoClassDefFoundError: play/db/NamedDatabaseImpl
        at play.api.db.slick.SlickModule.bindNamed(SlickModule.scala:51) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at play.api.db.slick.SlickModule$$anonfun$namedDatabaseConfigBindings$1.apply(SlickModule.scala:44) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at play.api.db.slick.SlickModule$$anonfun$namedDatabaseConfigBindings$1.apply(SlickModule.scala:43) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at scala.collection.immutable.List.map(List.scala:273) ~[scala-library-2.11.6.jar:na]
        at play.api.db.slick.SlickModule.namedDatabaseConfigBindings(SlickModule.scala:43) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at play.api.db.slick.SlickModule.bindings(SlickModule.scala:40) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at play.api.db.slick.SlickModule.bindings(SlickModule.scala:32) ~[play-slick_2.10.jar:1.0.1-SNAPSHOT]
        at play.api.inject.guice.GuiceableModuleConversions$class.guice(GuiceInjectorBuilder.scala:264) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceableModule$.guice(GuiceInjectorBuilder.scala:200) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceableModuleConversions$$anon$3$$anonfun$guiced$2.apply(GuiceInjectorBuilder.scala:244) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceableModuleConversions$$anon$3$$anonfun$guiced$2.apply(GuiceInjectorBuilder.scala:244) ~[play_2.11-2.4.2.jar:2.4.2]
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245) ~[scala-library-2.11.6.jar:na]
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245) ~[scala-library-2.11.6.jar:na]
        at scala.collection.immutable.List.foreach(List.scala:381) ~[scala-library-2.11.6.jar:na]
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:245) ~[scala-library-2.11.6.jar:na]
        at scala.collection.immutable.List.map(List.scala:285) ~[scala-library-2.11.6.jar:na]
        at play.api.inject.guice.GuiceableModuleConversions$$anon$3.guiced(GuiceInjectorBuilder.scala:244) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceableModule$$anonfun$guiced$1.apply(GuiceInjectorBuilder.scala:222) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceableModule$$anonfun$guiced$1.apply(GuiceInjectorBuilder.scala:222) ~[play_2.11-2.4.2.jar:2.4.2]
        at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:252) ~[scala-library-2.11.6.jar:na]
        at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:252) ~[scala-library-2.11.6.jar:na]
        at scala.collection.immutable.List.foreach(List.scala:381) ~[scala-library-2.11.6.jar:na]
        at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:252) ~[scala-library-2.11.6.jar:na]
        at scala.collection.immutable.List.flatMap(List.scala:344) ~[scala-library-2.11.6.jar:na]
        at play.api.inject.guice.GuiceableModule$.guiced(GuiceInjectorBuilder.scala:222) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceBuilder.createModule(GuiceInjectorBuilder.scala:116) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceApplicationBuilder.applicationModule(GuiceApplicationBuilder.scala:87) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) ~[play_2.11-2.4.2.jar:2.4.2]
        at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21) ~[play_2.11-2.4.2.jar:2.4.2]
        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.jar:2.4.0]
        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.jar:2.4.0]
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.4.2.jar:2.4.2]
        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.jar:2.4.0]
        ... 14 common frames omitted
Caused by: java.lang.ClassNotFoundException: play.db.NamedDatabaseImpl
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_40]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_40]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_40]
        ... 48 common frames omitted

What might I be doing wrong here?

liscovich avatar Aug 03 '15 18:08 liscovich

Okay, I managed to get it working. It looks like the problem was with my locally published .jars. Play-slick has just released version 1.1.0-M1 as a managed dependency, and replacing the unmanaged .jars with it eliminated the runtime errors. However, I'm still not sure what exactly caused the problem with my locally published .jars.

liscovich avatar Aug 03 '15 23:08 liscovich

I am getting this issue, or perhaps a related one?

I am using the following versions:

"com.typesafe.play" %% "play-slick" % "1.1.1",
   "com.github.tminglei" %% "slick-pg" % "0.10.0-M1",

If I start in dev mode I get

Failed to create Slick database config for key default.
slick.SlickException: Error getting instance of Slick driver "platform.models.database.MyPostgresDriver$"

If I run it in production mode I get this

Execution exception[[NoClassDefFoundError: slick/profile/BasicProfile$CommonImplicits]]
...
Caused by: java.lang.ClassNotFoundException: slick.profile.BasicProfile$CommonImplicits
...

adamgordonbell avatar Mar 30 '16 19:03 adamgordonbell

@agbell I can't reproduce it on my local. Can you help create/share a simple project to reproduce it? Thanks!

tminglei avatar Mar 31 '16 05:03 tminglei

Hi @tminglei

I did finally crack this issue. It turns out these errors were triggered by not including play slick evolutions in the library list. That does not make sense to me, as I don't use evolutions, but so be it.

adamgordonbell avatar Apr 08 '16 22:04 adamgordonbell

@agbell so, you resolved it?

tminglei avatar Apr 09 '16 01:04 tminglei

Yes, resolved

adamgordonbell avatar Apr 09 '16 01:04 adamgordonbell

Sounds good! :-)

tminglei avatar Apr 09 '16 04:04 tminglei

We had a somewhat similar problem and it wound up being fixed by identifying a syntax error in the config file. The stack traces weren't helpful, but this is what it turned out to be.

parallelepiped avatar Jul 26 '16 17:07 parallelepiped

I have the same issues with ClassDefNotFound with v0.15.0-M4 ;(

play.api.UnexpectedException: Unexpected exception[NoClassDefFoundError: slick/backend/DatabaseConfig]
	at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:184)
	at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:131)
	at scala.Option.map(Option.scala:146)
	at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:131)
	at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:129)
	at scala.util.Success.flatMap(Try.scala:231)
	at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:129)
	at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:121)
	at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
	at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
Caused by: java.lang.NoClassDefFoundError: slick/backend/DatabaseConfig

mine build.sbt

val playSlick = "2.0.0"
val slickPgVersion = "0.15.0-M4"
libraryDependencies ++= Seq(
  "com.typesafe.play" %% "play-slick" % playSlick,
  "com.typesafe.play" %% "play-slick-evolutions" % playSlick,
  "org.postgresql" % "postgresql" % "9.4.1208",
  "com.github.tminglei" %% "slick-pg" % slickPgVersion,
  "com.github.tminglei" %% "slick-pg_play-json" % slickPgVersion
)

satybald avatar Mar 10 '17 17:03 satybald

@satybald I ran into the same error you did and was able to resolve it by updating play-slick to 2.1.0.

brandondtb avatar Apr 25 '17 01:04 brandondtb