postgresql - How to configure Slick 3.0.0 for Postgres DB (either with Hikari or without) Typesafe Play conf -
i have test app works fine h2 in-memory database. i'm trying connect our real database. i'm either getting internal slick exception, or "no suitable driver" exception, depending on approach:
here's simple test (which, again, seems work fine in-memory):
"the glimple data model classes" should { "insert glimple row in database" in { val db = database.forconfig("db.edb") // works on db.h2mem1 val glimples = tablequery[gpglimplemodel] val insertglimples = db.run(glimples += gpglimple(none, none, 1, true, true, 1)) val count = await.result(insertglimples, duration.inf) println(count) count must beequalto(1) ...
if turn on connection pool, noted here:
db.edb = { driver = org.postgresql.driver url = "jdbc:postgresql://db-server-1.hyrax.com:5444/ci_0" user = "xxx" // masked protect innocent password = "xxx" // masked protect innocent keepaliveconnection = true // connectionpool = disabled }
i end getting following exception. in trying decipher what's going on, started connection pool enabled (as in, "connectionpool = enabled" or commenting line out). led more problems , very, long exception (shown @ end of post).
the head of exception is:
[error] [error] java.lang.noclassdeffounderror: com/zaxxer/hikari/hikariconfig [error] caused java.lang.classnotfoundexception: com.zaxxer.hikari.hikariconfig
and makes no sense me... because again, works fine in-memory.
and here's build.sbt driver line postgres:
"org.postgresql" % "postgresql" % "9.4-1201-jdbc41",
following full exception... i've posted github suggested @ end of trace:
[error] [error] java.lang.noclassdeffounderror: com/zaxxer/hikari/hikariconfig [error] caused java.lang.classnotfoundexception: com.zaxxer.hikari.hikariconfig [error] [error] stacktrace [error]
slick.jdbc.hikaricpjdbcdatasource$.forconfig(jdbcdatasource.scala:141) [error]
slick.jdbc.hikaricpjdbcdatasource$.forconfig(jdbcdatasource.scala:135) [error]
slick.jdbc.jdbcdatasource$.forconfig(jdbcdatasource.scala:35) [error] slick.jdbc.jdbcbackend$databasefactorydef$class.forconfig(jdbcbackend.scala:223) [error]
slick.jdbc.jdbcbackend$$anon$3.forconfig(jdbcbackend.scala:33) [error] models.testglimplemodel$$anonfun$1$$anonfun$apply$64$$anonfun$apply$65.apply(testglimplemodel.scala:166) [error]
models.testglimplemodel$$anonfun$1$$anonfun$apply$64$$anonfun$apply$65.apply(testglimplemodel.scala:158) [error]
org.specs2.matcher.matchresult$$anon$12$$anonfun$asresult$1.apply(matchresult.scala:310) [error]
org.specs2.matcher.matchresult$$anon$12$$anonfun$asresult$1.apply(matchresult.scala:310) [error]
org.specs2.execute.resultexecution$class.execute(resultexecution.scala:25) [error]
org.specs2.execute.resultexecution$.execute(resultexecution.scala:120) [error]
org.specs2.execute.result$$anon$10.asresult(result.scala:230) [error] org.specs2.execute.asresult$.apply(asresult.scala:25) [error]
org.specs2.matcher.matchresult$$anon$12.asresult(matchresult.scala:310) [error] org.specs2.execute.asresult$.apply(asresult.scala:25) [error]
org.specs2.main.commandlineasresult$$anon$1.asresult(commandlineasresult.scala:17) [error]
org.specs2.main.commandlineasresult$$anonfun$apply$1.apply(commandlineasresult.scala:21) [error]
org.specs2.main.commandlineasresult$$anonfun$apply$1.apply(commandlineasresult.scala:21) [error]
org.specs2.specification.dsl.mutable.exampledsl1$blockexample$$anonfun$$greater$greater$1.apply(exampledsl.scala:39) [error]
org.specs2.specification.dsl.mutable.exampledsl1$blockexample$$anonfun$$greater$greater$1.apply(exampledsl.scala:39) [error]
org.specs2.specification.core.execution$$anonfun$withenv$1$$anonfun$apply$3.apply(execution.scala:120) [error]
org.specs2.execute.resultexecution$class.execute(resultexecution.scala:25) [error]
org.specs2.execute.resultexecution$.execute(resultexecution.scala:120) [error]
org.specs2.execute.result$$anon$10.asresult(result.scala:230) [error] org.specs2.execute.asresult$.apply(asresult.scala:25) [error]
org.specs2.specification.core.execution$$anonfun$withenv$1.apply(execution.scala:120) [error]
org.specs2.specification.core.execution$$anonfun$withenv$1.apply(execution.scala:120) [error]
org.specs2.specification.core.execution$$anonfun$execute$2$$anonfun$apply$2.apply(execution.scala:70) [error]
org.specs2.specification.core.execution$$anonfun$execute$2$$anonfun$apply$2.apply(execution.scala:70) [error]
org.specs2.specification.core.execution.setresult(execution.scala:76) [error]
org.specs2.specification.core.execution$$anonfun$execute$2.apply(execution.scala:70) [error]
org.specs2.specification.core.execution$$anonfun$execute$2.apply(execution.scala:70) [error] scala.option.fold(option.scala:158) [error]
org.specs2.specification.core.execution.execute(execution.scala:70) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$executefragment$1$$anonfun$apply$6.apply(executor.scala:132) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$executefragment$1$$anonfun$apply$6.apply(executor.scala:130) [error]
org.specs2.specification.core.fragment.updateexecution(fragment.scala:44) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$executefragment$1.apply(executor.scala:130) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$executefragment$1.apply(executor.scala:129) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$sequencedexecution$1.executedfragment$lzycompute$1(executor.scala:104) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$sequencedexecution$1.org$specs2$specification$process$defaultexecutor$class$$anonfun$$executedfragment$1(executor.scala:104) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$sequencedexecution$1$$anonfun$3.apply(executor.scala:109) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$sequencedexecution$1$$anonfun$3.apply(executor.scala:109) [error]
scalaz.concurrent.task$$anonfun$delay$1.apply(task.scala:272) [error] scalaz.concurrent.task$$anonfun$delay$1.apply(task.scala:272) [error] scalaz.concurrent.task$$anonfun$suspend$1$$anonfun$4.apply(task.scala:280) [error]
scalaz.concurrent.task$$anonfun$suspend$1$$anonfun$4.apply(task.scala:280) [error] scalaz.concurrent.task$.try(task.scala:385) [error]
scalaz.concurrent.task$$anonfun$suspend$1.apply(task.scala:280) [error]
scalaz.concurrent.task$$anonfun$suspend$1.apply(task.scala:280) [error] scalaz.concurrent.future.step(future.scala:111) [error]
scalaz.concurrent.future.listen(future.scala:76) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:310) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:309) [error] scala.collection.iterator$class.foreach(iterator.scala:750) [error]
scala.collection.abstractiterator.foreach(iterator.scala:1202) [error] scala.collection.iterablelike$class.foreach(iterablelike.scala:72) [error] scala.collection.abstractiterable.foreach(iterable.scala:54) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:309) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:305) [error] scalaz.concurrent.future.listen(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error] scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free.resume(free.scala:73) [error]
scalaz.free.go2$1(free.scala:118) [error]
scalaz.free.go(free.scala:122) [error]
scalaz.free.run(free.scala:172) [error]
scalaz.concurrent.future.listen(future.scala:77) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:310) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:309) [error] scala.collection.iterator$class.foreach(iterator.scala:750) [error]
scala.collection.abstractiterator.foreach(iterator.scala:1202) [error] scala.collection.iterablelike$class.foreach(iterablelike.scala:72) [error] scala.collection.abstractiterable.foreach(iterable.scala:54) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:309) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:305) [error] scalaz.concurrent.future.listen(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error] scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free.resume(free.scala:73) [error]
scalaz.free.go2$1(free.scala:118) [error]
scalaz.free.go(free.scala:122) [error]
scalaz.free.run(free.scala:172) [error]
scalaz.concurrent.future.listen(future.scala:77) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:310) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:309) [error] scala.collection.iterator$class.foreach(iterator.scala:750) [error]
scala.collection.abstractiterator.foreach(iterator.scala:1202) [error] scala.collection.iterablelike$class.foreach(iterablelike.scala:72) [error] scala.collection.abstractiterable.foreach(iterable.scala:54) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:309) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:305) [error] scalaz.concurrent.future.listen(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error] scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free.resume(free.scala:73) [error]
scalaz.free.go2$1(free.scala:118) [error]
scalaz.free.go(free.scala:122) [error]
scalaz.free.run(free.scala:172) [error]
scalaz.concurrent.future.listen(future.scala:77) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:310) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:309) [error] scala.collection.iterator$class.foreach(iterator.scala:750) [error]
scala.collection.abstractiterator.foreach(iterator.scala:1202) [error] scala.collection.iterablelike$class.foreach(iterablelike.scala:72) [error] scala.collection.abstractiterable.foreach(iterable.scala:54) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:309) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:305) [error] scalaz.concurrent.future.listen(future.scala:80) [error]
scalaz.concurrent.future.runasync(future.scala:143) [error]
scalaz.concurrent.future.run(future.scala:160) [error]
scalaz.concurrent.task.attemptrun(task.scala:104) [error]
org.specs2.control.actiont$.fromtask(actiont.scala:125) [error]
org.specs2.control.actiontsupport$class.fromtask(actiont.scala:188) [error]
org.specs2.control.package$actions$.fromtask(package.scala:29) [error] org.specs2.reporter.reporter$$anonfun$report$1.apply(reporter.scala:47) [error]
org.specs2.reporter.reporter$$anonfun$report$1.apply(reporter.scala:37) [error]
org.specs2.runner.sbtrunner$$anonfun$specificationrun$1$$anonfun$2.apply(sbtrunner.scala:75) [error]
org.specs2.runner.sbtrunner$$anonfun$specificationrun$1$$anonfun$2.apply(sbtrunner.scala:75) [error]
org.specs2.control.actiont$$anonfun$flatmap$1$$anonfun$apply$2.apply(actiont.scala:36) [error]
org.specs2.control.actiont$$anonfun$flatmap$1$$anonfun$apply$2.apply(actiont.scala:36) [error]
org.specs2.control.statust$$anonfun$flatmap$1.apply(statust.scala:20) [error]
org.specs2.control.statust$$anonfun$flatmap$1.apply(statust.scala:19) [error] scala.function1$$anonfun$andthen$1.apply(function1.scala:55) [error] scalaz.writert$$anonfun$flatmapf$1.apply(writert.scala:63) [error] scalaz.writert$$anonfun$flatmapf$1.apply(writert.scala:62) [error]
scalaz.effect.io$$anonfun$flatmap$1$$anonfun$apply$9.apply(io.scala:62) [error]
scalaz.effect.io$$anonfun$flatmap$1$$anonfun$apply$9.apply(io.scala:61) [error]
scalaz.free$$anonfun$flatmap$1$$anonfun$apply$1.apply(free.scala:60) [error]
scalaz.free$$anonfun$flatmap$1$$anonfun$apply$1.apply(free.scala:60) [error] scalaz.free.resume(free.scala:72) [error]
scalaz.free.go2$1(free.scala:118) [error]
scalaz.free.go(free.scala:122) [error]
scalaz.free.run(free.scala:172) [error]
scalaz.effect.io$class.unsafeperformio(io.scala:22) [error]
scalaz.effect.iofunctions$$anon$6.unsafeperformio(io.scala:227) [error]
org.specs2.runner.sbtrunner$$anonfun$newtask$1$$anon$4.execute(sbtrunner.scala:40) [error] sbt.forkmain$run$2.call(forkmain.java:294) [error]
sbt.forkmain$run$2.call(forkmain.java:284) [error]
java.util.concurrent.futuretask.run(futuretask.java:266) [error]
java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) [error]
java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) [error] java.lang.thread.run(thread.java:745) [error] [error]
caused java.lang.classnotfoundexception: com.zaxxer.hikari.hikariconfig [error]
java.net.urlclassloader$1.run(urlclassloader.java:372) [error]
java.net.urlclassloader$1.run(urlclassloader.java:361) [error]
java.security.accesscontroller.doprivileged(native method) [error]
java.net.urlclassloader.findclass(urlclassloader.java:360) [error]
java.lang.classloader.loadclass(classloader.java:424) [error]
sun.misc.launcher$appclassloader.loadclass(launcher.java:308) [error] java.lang.classloader.loadclass(classloader.java:357) [error]
slick.jdbc.hikaricpjdbcdatasource$.forconfig(jdbcdatasource.scala:141) [error]
slick.jdbc.hikaricpjdbcdatasource$.forconfig(jdbcdatasource.scala:135) [error]
slick.jdbc.jdbcdatasource$.forconfig(jdbcdatasource.scala:35) [error] slick.jdbc.jdbcbackend$databasefactorydef$class.forconfig(jdbcbackend.scala:223) [error]
slick.jdbc.jdbcbackend$$anon$3.forconfig(jdbcbackend.scala:33) [error] models.testglimplemodel$$anonfun$1$$anonfun$apply$64$$anonfun$apply$65.apply(testglimplemodel.scala:166) [error]
models.testglimplemodel$$anonfun$1$$anonfun$apply$64$$anonfun$apply$65.apply(testglimplemodel.scala:158) [error]
org.specs2.matcher.matchresult$$anon$12$$anonfun$asresult$1.apply(matchresult.scala:310) [error]
org.specs2.matcher.matchresult$$anon$12$$anonfun$asresult$1.apply(matchresult.scala:310) [error]
org.specs2.execute.resultexecution$class.execute(resultexecution.scala:25) [error]
org.specs2.execute.resultexecution$.execute(resultexecution.scala:120) [error]
org.specs2.execute.result$$anon$10.asresult(result.scala:230) [error] org.specs2.execute.asresult$.apply(asresult.scala:25) [error]
org.specs2.matcher.matchresult$$anon$12.asresult(matchresult.scala:310) [error] org.specs2.execute.asresult$.apply(asresult.scala:25) [error]
org.specs2.main.commandlineasresult$$anon$1.asresult(commandlineasresult.scala:17) [error]
org.specs2.main.commandlineasresult$$anonfun$apply$1.apply(commandlineasresult.scala:21) [error]
org.specs2.main.commandlineasresult$$anonfun$apply$1.apply(commandlineasresult.scala:21) [error]
org.specs2.specification.dsl.mutable.exampledsl1$blockexample$$anonfun$$greater$greater$1.apply(exampledsl.scala:39) [error]
org.specs2.specification.dsl.mutable.exampledsl1$blockexample$$anonfun$$greater$greater$1.apply(exampledsl.scala:39) [error]
org.specs2.specification.core.execution$$anonfun$withenv$1$$anonfun$apply$3.apply(execution.scala:120) [error]
org.specs2.execute.resultexecution$class.execute(resultexecution.scala:25) [error]
org.specs2.execute.resultexecution$.execute(resultexecution.scala:120) [error]
org.specs2.execute.result$$anon$10.asresult(result.scala:230) [error] org.specs2.execute.asresult$.apply(asresult.scala:25) [error]
org.specs2.specification.core.execution$$anonfun$withenv$1.apply(execution.scala:120) [error]
org.specs2.specification.core.execution$$anonfun$withenv$1.apply(execution.scala:120) [error]
org.specs2.specification.core.execution$$anonfun$execute$2$$anonfun$apply$2.apply(execution.scala:70) [error]
org.specs2.specification.core.execution$$anonfun$execute$2$$anonfun$apply$2.apply(execution.scala:70) [error]
org.specs2.specification.core.execution.setresult(execution.scala:76) [error]
org.specs2.specification.core.execution$$anonfun$execute$2.apply(execution.scala:70) [error]
org.specs2.specification.core.execution$$anonfun$execute$2.apply(execution.scala:70) [error] scala.option.fold(option.scala:158) [error]
org.specs2.specification.core.execution.execute(execution.scala:70) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$executefragment$1$$anonfun$apply$6.apply(executor.scala:132) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$executefragment$1$$anonfun$apply$6.apply(executor.scala:130) [error]
org.specs2.specification.core.fragment.updateexecution(fragment.scala:44) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$executefragment$1.apply(executor.scala:130) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$executefragment$1.apply(executor.scala:129) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$sequencedexecution$1.executedfragment$lzycompute$1(executor.scala:104) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$sequencedexecution$1.org$specs2$specification$process$defaultexecutor$class$$anonfun$$executedfragment$1(executor.scala:104) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$sequencedexecution$1$$anonfun$3.apply(executor.scala:109) [error]
org.specs2.specification.process.defaultexecutor$$anonfun$sequencedexecution$1$$anonfun$3.apply(executor.scala:109) [error]
scalaz.concurrent.task$$anonfun$delay$1.apply(task.scala:272) [error] scalaz.concurrent.task$$anonfun$delay$1.apply(task.scala:272) [error] scalaz.concurrent.task$$anonfun$suspend$1$$anonfun$4.apply(task.scala:280) [error]
scalaz.concurrent.task$$anonfun$suspend$1$$anonfun$4.apply(task.scala:280) [error] scalaz.concurrent.task$.try(task.scala:385) [error]
scalaz.concurrent.task$$anonfun$suspend$1.apply(task.scala:280) [error]
scalaz.concurrent.task$$anonfun$suspend$1.apply(task.scala:280) [error] scalaz.concurrent.future.step(future.scala:111) [error]
scalaz.concurrent.future.listen(future.scala:76) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:310) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:309) [error] scala.collection.iterator$class.foreach(iterator.scala:750) [error]
scala.collection.abstractiterator.foreach(iterator.scala:1202) [error] scala.collection.iterablelike$class.foreach(iterablelike.scala:72) [error] scala.collection.abstractiterable.foreach(iterable.scala:54) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:309) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:305) [error] scalaz.concurrent.future.listen(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error] scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free.resume(free.scala:73) [error]
scalaz.free.go2$1(free.scala:118) [error]
scalaz.free.go(free.scala:122) [error]
scalaz.free.run(free.scala:172) [error]
scalaz.concurrent.future.listen(future.scala:77) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:310) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:309) [error] scala.collection.iterator$class.foreach(iterator.scala:750) [error]
scala.collection.abstractiterator.foreach(iterator.scala:1202) [error] scala.collection.iterablelike$class.foreach(iterablelike.scala:72) [error] scala.collection.abstractiterable.foreach(iterable.scala:54) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:309) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:305) [error] scalaz.concurrent.future.listen(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error] scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free.resume(free.scala:73) [error]
scalaz.free.go2$1(free.scala:118) [error]
scalaz.free.go(free.scala:122) [error]
scalaz.free.run(free.scala:172) [error]
scalaz.concurrent.future.listen(future.scala:77) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:310) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:309) [error] scala.collection.iterator$class.foreach(iterator.scala:750) [error]
scala.collection.abstractiterator.foreach(iterator.scala:1202) [error] scala.collection.iterablelike$class.foreach(iterablelike.scala:72) [error] scala.collection.abstractiterable.foreach(iterable.scala:54) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:309) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:305) [error] scalaz.concurrent.future.listen(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error]
scalaz.concurrent.future$$anonfun$listen$1$$anonfun$apply$4.apply(future.scala:80) [error] scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free$$anonfun$map$1.apply(free.scala:52) [error]
scalaz.free.resume(free.scala:73) [error]
scalaz.free.go2$1(free.scala:118) [error]
scalaz.free.go(free.scala:122) [error]
scalaz.free.run(free.scala:172) [error]
scalaz.concurrent.future.listen(future.scala:77) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:310) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2$$anonfun$apply$10.apply(future.scala:309) [error] scala.collection.iterator$class.foreach(iterator.scala:750) [error]
scala.collection.abstractiterator.foreach(iterator.scala:1202) [error] scala.collection.iterablelike$class.foreach(iterablelike.scala:72) [error] scala.collection.abstractiterable.foreach(iterable.scala:54) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:309) [error]
scalaz.concurrent.future$$anon$1$$anonfun$reduceunordered$2.apply(future.scala:305) [error] scalaz.concurrent.future.listen(future.scala:80) [error]
scalaz.concurrent.future.runasync(future.scala:143) [error]
scalaz.concurrent.future.run(future.scala:160) [error]
scalaz.concurrent.task.attemptrun(task.scala:104) [error]
org.specs2.control.actiont$.fromtask(actiont.scala:125) [error]
org.specs2.control.actiontsupport$class.fromtask(actiont.scala:188) [error]
org.specs2.control.package$actions$.fromtask(package.scala:29) [error] org.specs2.reporter.reporter$$anonfun$report$1.apply(reporter.scala:47) [error]
org.specs2.reporter.reporter$$anonfun$report$1.apply(reporter.scala:37) [error]
org.specs2.runner.sbtrunner$$anonfun$specificationrun$1$$anonfun$2.apply(sbtrunner.scala:75) [error]
org.specs2.runner.sbtrunner$$anonfun$specificationrun$1$$anonfun$2.apply(sbtrunner.scala:75) [error]
org.specs2.control.actiont$$anonfun$flatmap$1$$anonfun$apply$2.apply(actiont.scala:36) [error]
org.specs2.control.actiont$$anonfun$flatmap$1$$anonfun$apply$2.apply(actiont.scala:36) [error]
org.specs2.control.statust$$anonfun$flatmap$1.apply(statust.scala:20) [error]
org.specs2.control.statust$$anonfun$flatmap$1.apply(statust.scala:19) [error] scala.function1$$anonfun$andthen$1.apply(function1.scala:55) [error] scalaz.writert$$anonfun$flatmapf$1.apply(writert.scala:63) [error] scalaz.writert$$anonfun$flatmapf$1.apply(writert.scala:62) [error]
scalaz.effect.io$$anonfun$flatmap$1$$anonfun$apply$9.apply(io.scala:62) [error]
scalaz.effect.io$$anonfun$flatmap$1$$anonfun$apply$9.apply(io.scala:61) [error]
scalaz.free$$anonfun$flatmap$1$$anonfun$apply$1.apply(free.scala:60) [error]
scalaz.free$$anonfun$flatmap$1$$anonfun$apply$1.apply(free.scala:60) [error] scalaz.free.resume(free.scala:72) [error]
scalaz.free.go2$1(free.scala:118) [error]
scalaz.free.go(free.scala:122) [error]
scalaz.free.run(free.scala:172) [error]
scalaz.effect.io$class.unsafeperformio(io.scala:22) [error]
scalaz.effect.iofunctions$$anon$6.unsafeperformio(io.scala:227) [error]
org.specs2.runner.sbtrunner$$anonfun$newtask$1$$anon$4.execute(sbtrunner.scala:40) [error] sbt.forkmain$run$2.call(forkmain.java:294) [error]
sbt.forkmain$run$2.call(forkmain.java:284) [error]
java.util.concurrent.futuretask.run(futuretask.java:266) [error]
java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) [error]
java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) [error] java.lang.thread.run(thread.java:745) [error] [error] [error] looks specs2 exception... [error] please report preceding stacktrace @ http://github.com/etorreborre/specs2/issues
one solution basic user on application.conf
play.modules.enabled += "modules.databasemodule" mynameis = { database = { driver = org.postgresql.driver url = "jdbc:postgresql://localhost:5432/databasename" user = "postgreuser" password = "" numthreads = 10 connectiontimeout = 5000 validationtimeout = 5000 } dispatcher { fork-join-executor { parallelism-factor = 2 parallelism-max = 20 } }
on dir app can create database module this
import javax.inject.{provider, inject, singleton} import com.google.inject.abstractmodule import com.typesafe.config.config import play.api.inject.applicationlifecycle import play.api.{configuration, environment} import slick.jdbc.jdbcbackend import scala.concurrent.future class databasemodule(environment: environment, configuration: configuration) extends abstractmodule { override def configure(): unit = { bind(classof[config]).toinstance(configuration.underlying) bind(classof[slick.jdbc.jdbcbackend.database]).toprovider(classof[databaseprovider]) bind(classof[models.userdao]).aseagersingleton() } } @singleton class databaseprovider @inject() (config: config, lifecycle: applicationlifecycle) extends provider[slick.jdbc.jdbcbackend.database] { private val db = slick.jdbc.jdbcbackend.database.forconfig("mynameis.database", config) lifecycle.addstophook { () => future.successful(db.close()) } override def get(): jdbcbackend.databasedef = db }
on app/models: userdao
import java.sql.date import javax.inject.{inject, singleton} import com.typesafe.config.config import slick.driver.postgresdriver.api._ import scala.concurrent.future import scala.concurrent.executioncontext.implicits.global case class user(id: option[long] = none, name: string, firstname: string, email: string, password: string, birthday: option[date] = none, signdate: option[date] = some(new date(system.currenttimemillis))) @singleton class userdao @inject()(config: config, db: database) { private val users = tablequery[users] override def delete(ids: long*): future[boolean] = { future.sequence(for (id <- ids) yield { db.run(users.filter(_.id === id).delete).map(_ == 1) }).map { _.find(i => == false) == none } } def insert(user: user): future[unit] = db.run(users += user).map{()} override def update(obj: user): future[boolean] = ??? override def create(obj: user): future[boolean] = db.run(users += obj).map(_ == 1) override def all: future[seq[user]] = db.run(users.result) private class users(tag: slick.lifted.tag) extends table[user](tag, "user") { type s = string type d = date type l = long // attribute name in table database def id = column[l](id, o.autoinc, o.primarykey) def name = column[s](name) def password = column[s](password) def firstname = column[s](firstname) def email = column[s](email) def birthday = column[d](birthday) def signdate = column[d](sign_date) override def * = (id.?, name, firstname, email, password, birthday.?, signdate.?) <> ((user.apply _) .tupled, user.unapply _) } }
on controllers application.scala
@singleton class application @inject()(userdao: userdao) extends controller { code }
and on route file:
# home page / @controllers.application.index
Comments
Post a Comment