Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Slick driver #266

Closed
ploddi opened this issue May 27, 2015 · 9 comments
Closed

Custom Slick driver #266

ploddi opened this issue May 27, 2015 · 9 comments
Milestone

Comments

@ploddi
Copy link

@ploddi ploddi commented May 27, 2015

User defined driver class (i.e. for using slick-pg library) can not be found by PlayDependencyClassLoader in Dev mode.

@jroper
Copy link
Member

@jroper jroper commented May 27, 2015

What version of play-slick are you using?

@ploddi
Copy link
Author

@ploddi ploddi commented May 27, 2015

Play-slick for Play 2.4 and Slick 3.0

@ploddi
Copy link
Author

@ploddi ploddi commented May 27, 2015

DatabaseConfig.forConfig throws ClassNotFound exception when calling Class.forName(n).

@jroper
Copy link
Member

@jroper jroper commented May 28, 2015

Ok, could you post the full stack trace of that?

@ploddi
Copy link
Author

@ploddi ploddi commented May 28, 2015

%PARSER_ERROR[coloredLevel] - play.api.db.slick.DefaultSlickApi - Failed to create Slick database config for key default.
slick.SlickException: Error getting instance of Slick driver "util.PimpedPostgresDriver$"
    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]
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get$lzycompute(SlickApi.scala:81) [play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get(SlickApi.scala:80) [play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi$$anonfun$allDbConfigs$1.apply(SlickApi.scala:59) [play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi$$anonfun$allDbConfigs$1.apply(SlickApi.scala:59) [play-slick_2.11-1.0.0.jar:1.0.0]
    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.Map$Map1.foreach(Map.scala:116) [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.AbstractTraversable.map(Traversable.scala:104) [scala-library-2.11.6.jar:na]
    at play.api.db.slick.DefaultSlickApi.allDbConfigs$lzycompute(SlickApi.scala:59) [play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi.allDbConfigs(SlickApi.scala:58) [play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi.dbConfigs(SlickApi.scala:62) [play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.evolutions.internal.DBApiAdapter.databasesByName$lzycompute(DBApiAdapter.scala:19) [play-slick-evolutions_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.evolutions.internal.DBApiAdapter.databasesByName(DBApiAdapter.scala:19) [play-slick-evolutions_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.evolutions.internal.DBApiAdapter.databases(DBApiAdapter.scala:23) [play-slick-evolutions_2.11-1.0.0.jar:1.0.0]
    at play.api.db.evolutions.ApplicationEvolutions.start(ApplicationEvolutions.scala:42) [play-jdbc-evolutions_2.11-2.4.0.jar:2.4.0]
    at play.api.db.evolutions.ApplicationEvolutions.<init>(ApplicationEvolutions.scala:149) [play-jdbc-evolutions_2.11-2.4.0.jar:2.4.0]
    at play.api.db.evolutions.ApplicationEvolutionsProvider.get$lzycompute(EvolutionsModule.scala:53) [play-jdbc-evolutions_2.11-2.4.0.jar:2.4.0]
    at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:53) [play-jdbc-evolutions_2.11-2.4.0.jar:2.4.0]
    at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:44) [play-jdbc-evolutions_2.11-2.4.0.jar:2.4.0]
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81) [guice-4.0.jar:na]
    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72) [guice-4.0.jar:na]
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61) [guice-4.0.jar:na]
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62) [guice-4.0.jar:na]
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46) [guice-4.0.jar:na]
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103) [guice-4.0.jar:na]
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) [guice-4.0.jar:na]
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145) [guice-4.0.jar:na]
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41) [guice-4.0.jar:na]
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205) [guice-4.0.jar:na]
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199) [guice-4.0.jar:na]
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092) [guice-4.0.jar:na]
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199) [guice-4.0.jar:na]
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180) [guice-4.0.jar:na]
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110) [guice-4.0.jar:na]
    at com.google.inject.Guice.createInjector(Guice.java:96) [guice-4.0.jar:na]
    at com.google.inject.Guice.createInjector(Guice.java:73) [guice-4.0.jar:na]
    at com.google.inject.Guice.createInjector(Guice.java:62) [guice-4.0.jar:na]
    at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126) [play_2.11-2.4.0.jar:2.4.0]
    at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) [play_2.11-2.4.0.jar:2.4.0]
    at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21) [play_2.11-2.4.0.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:153) [play-server_2.11-2.4.0.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-2.4.0.jar:2.4.0]
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21) [play_2.11-2.4.0.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:150) [play-server_2.11-2.4.0.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-2.4.0.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-2.4.0.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-2.4.0.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-2.4.0.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-2.4.0.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_45]
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [na:1.8.0_45]
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [na:1.8.0_45]
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689) [na:1.8.0_45]
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [na:1.8.0_45]
Caused by: java.lang.ClassNotFoundException: util.PimpedPostgresDriver$
    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
%PARSER_ERROR[coloredLevel] - application -

! @6m9oj4l7g - Internal server error, for (GET) [/] ->

play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [default]]
    at play.api.Configuration$.configError(Configuration.scala:178) ~[play_2.11-2.4.0.jar:2.4.0]
    at play.api.Configuration.reportError(Configuration.scala:829) ~[play_2.11-2.4.0.jar:2.4.0]
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.create(SlickApi.scala:93) ~[play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get$lzycompute(SlickApi.scala:81) ~[play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get(SlickApi.scala:80) ~[play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi$$anonfun$allDbConfigs$1.apply(SlickApi.scala:59) ~[play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi$$anonfun$allDbConfigs$1.apply(SlickApi.scala:59) ~[play-slick_2.11-1.0.0.jar:1.0.0]
    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.Map$Map1.foreach(Map.scala:116) ~[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.AbstractTraversable.map(Traversable.scala:104) ~[scala-library-2.11.6.jar:na]
    at play.api.db.slick.DefaultSlickApi.allDbConfigs$lzycompute(SlickApi.scala:59) ~[play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi.allDbConfigs(SlickApi.scala:58) ~[play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.DefaultSlickApi.dbConfigs(SlickApi.scala:62) ~[play-slick_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.evolutions.internal.DBApiAdapter.databasesByName$lzycompute(DBApiAdapter.scala:19) ~[play-slick-evolutions_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.evolutions.internal.DBApiAdapter.databasesByName(DBApiAdapter.scala:19) ~[play-slick-evolutions_2.11-1.0.0.jar:1.0.0]
    at play.api.db.slick.evolutions.internal.DBApiAdapter.databases(DBApiAdapter.scala:23) ~[play-slick-evolutions_2.11-1.0.0.jar:1.0.0]
    at play.api.db.evolutions.ApplicationEvolutions.start(ApplicationEvolutions.scala:42) ~[play-jdbc-evolutions_2.11-2.4.0.jar:2.4.0]
    at play.api.db.evolutions.ApplicationEvolutions.<init>(ApplicationEvolutions.scala:149) ~[play-jdbc-evolutions_2.11-2.4.0.jar:2.4.0]
    at play.api.db.evolutions.ApplicationEvolutionsProvider.get$lzycompute(EvolutionsModule.scala:53) ~[play-jdbc-evolutions_2.11-2.4.0.jar:2.4.0]
    at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:53) ~[play-jdbc-evolutions_2.11-2.4.0.jar:2.4.0]
    at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:44) ~[play-jdbc-evolutions_2.11-2.4.0.jar:2.4.0]
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81) ~[guice-4.0.jar:na]
    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72) ~[guice-4.0.jar:na]
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61) ~[guice-4.0.jar:na]
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62) ~[guice-4.0.jar:na]
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46) ~[guice-4.0.jar:na]
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103) ~[guice-4.0.jar:na]
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) ~[guice-4.0.jar:na]
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145) ~[guice-4.0.jar:na]
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41) ~[guice-4.0.jar:na]
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205) ~[guice-4.0.jar:na]
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199) ~[guice-4.0.jar:na]
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092) ~[guice-4.0.jar:na]
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199) ~[guice-4.0.jar:na]
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180) ~[guice-4.0.jar:na]
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110) ~[guice-4.0.jar:na]
    at com.google.inject.Guice.createInjector(Guice.java:96) ~[guice-4.0.jar:na]
    at com.google.inject.Guice.createInjector(Guice.java:73) ~[guice-4.0.jar:na]
    at com.google.inject.Guice.createInjector(Guice.java:62) ~[guice-4.0.jar:na]
    at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126) ~[play_2.11-2.4.0.jar:2.4.0]
    at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) ~[play_2.11-2.4.0.jar:2.4.0]
    at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21) ~[play_2.11-2.4.0.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:153) ~[play-server_2.11-2.4.0.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-2.4.0.jar:2.4.0]
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.4.0.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:150) ~[play-server_2.11-2.4.0.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-2.4.0.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-2.4.0.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-2.4.0.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-2.4.0.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-2.4.0.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_45]
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[na:1.8.0_45]
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[na:1.8.0_45]
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689) ~[na:1.8.0_45]
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[na:1.8.0_45]
Caused by: slick.SlickException: Error getting instance of Slick driver "util.PimpedPostgresDriver$"
    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: util.PimpedPostgresDriver$
    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```
@ploddi
Copy link
Author

@ploddi ploddi commented May 28, 2015

All works fine in production mode.

@jroper
Copy link
Member

@jroper jroper commented May 28, 2015

The problem is in slick, see slick/slick#1152.

@dotta
Copy link
Contributor

@dotta dotta commented Aug 3, 2015

Fix will be available in Slick 3.0.1 (and, once released, in play-slick 1.0.1).

@dotta dotta added this to the 1.0.1 milestone Aug 3, 2015
@dotta dotta added the closed:invalid label Aug 3, 2015
@dotta dotta closed this Aug 3, 2015
@helllamer
Copy link

@helllamer helllamer commented Dec 7, 2015

Saw this issue today on play-slick 1.1.1 with slick-3.1.0 and play-2.4.4.

PR slick/slick#1152 adds only an ability to pass instance of ClassLoader into DatabaseConfig.forConfig() in 3rd optional parameter, isn't it?
1152 does not fixes anything, only adds a feature.

But SlickApi.scala#L89 does not passing any Enviroment.classLoader info forConfig().

I'm not specialist in classLoaders, but is this hypothesis correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants