4

当我想使用 PlayJongo 在 mongodb 中填充数据库时出现错误。

我收到了这个错误

[error] - play.core.server.netty.PlayDefaultUpstreamHandler - Cannot invoke the action
java.lang.NullPointerException: null
        at java.net.URLEncoder.encode(URLEncoder.java:204) ~[na:1.8.0_60]
        at play.api.mvc.CookieBaker$$anonfun$4.apply(Http.scala:501) ~[play_2.11-2.4.3.jar:2.4.3]
        at play.api.mvc.CookieBaker$$anonfun$4.apply(Http.scala:500) ~[play_2.11-2.4.3.jar:2.4.3]
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245) ~[scala-library-2.11.7.jar:na]
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245) ~[scala-library-2.11.7.jar:na]
        at scala.collection.immutable.Map$Map1.foreach(Map.scala:116) ~[scala-library-2.11.7.jar:na]
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:245) ~[scala-library-2.11.7.jar:na]
        at scala.collection.AbstractTraversable.map(Traversable.scala:104) ~[scala-library-2.11.7.jar:na]
        at play.api.mvc.CookieBaker$class.encode(Http.scala:500) ~[play_2.11-2.4.3.jar:2.4.3]
        at play.api.mvc.Session$.encode(Http.scala:653) ~[play_2.11-2.4.3.jar:2.4.3]
        at play.api.mvc.CookieBaker$class.encodeAsCookie(Http.scala:556) ~[play_2.11-2.4.3.jar:2.4.3]
        at play.api.mvc.Session$.encodeAsCookie(Http.scala:653) ~[play_2.11-2.4.3.jar:2.4.3]
        at play.api.mvc.Result.withSession(Results.scala:170) ~[play_2.11-2.4.3.jar:2.4.3]
        at play.core.j.JavaHelpers$class.createResult(JavaHelpers.scala:64) ~[play_2.11-2.4.3.jar:2.4.3]
        at play.core.j.JavaAction.createResult(JavaAction.scala:55) ~[play_2.11-2.4.3.jar:2.4.3]
        at play.core.j.JavaAction$$anonfun$9.apply(JavaAction.scala:96) ~[play_2.11-2.4.3.jar:2.4.3]
        at play.core.j.JavaAction$$anonfun$9.apply(JavaAction.scala:96) ~[play_2.11-2.4.3.jar:2.4.3]
        at scala.util.Success$$anonfun$map$1.apply(Try.scala:237) ~[scala-library-2.11.7.jar:na]
        at scala.util.Try$.apply(Try.scala:192) ~[scala-library-2.11.7.jar:na]
        at scala.util.Success.map(Try.scala:237) ~[scala-library-2.11.7.jar:na]
        at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235) ~[scala-library-2.11.7.jar:na]
        at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235) ~[scala-library-2.11.7.jar:na]
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [scala-library-2.11.7.jar:na]
        at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:70) ~[play-iteratees_2.11-2.4.3.jar:2.4.3]
        at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) [scala-library-2.11.7.jar:na]
        at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248) [scala-library-2.11.7.jar:na]
        at scala.concurrent.Promise$class.complete(Promise.scala:55) [scala-library-2.11.7.jar:na]
        at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:153) [scala-library-2.11.7.jar:na]
        at scala.concurrent.Future$$anonfun$flatMap$1$$anonfun$apply$3.apply(Future.scala:254) [scala-library-2.11.7.jar:na]
        at scala.concurrent.Future$$anonfun$flatMap$1$$anonfun$apply$3.apply(Future.scala:254) [scala-library-2.11.7.jar:na]
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [scala-library-2.11.7.jar:na]
        at scala.concurrent.BatchingExecutor$Batch$$anonfun$run$1.processBatch$1(BatchingExecutor.scala:63) [scala-library-2.11.7.jar:na]
        at scala.concurrent.BatchingExecutor$Batch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:78) [scala-library-2.11.7.jar:na]
        at scala.concurrent.BatchingExecutor$Batch$$anonfun$run$1.apply(BatchingExecutor.scala:55) [scala-library-2.11.7.jar:na]
        at scala.concurrent.BatchingExecutor$Batch$$anonfun$run$1.apply(BatchingExecutor.scala:55) [scala-library-2.11.7.jar:na]
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72) [scala-library-2.11.7.jar:na]
        at scala.concurrent.BatchingExecutor$Batch.run(BatchingExecutor.scala:54) [scala-library-2.11.7.jar:na]
        at scala.concurrent.Future$InternalCallbackExecutor$.unbatchedExecute(Future.scala:599) [scala-library-2.11.7.jar:na]
        at scala.concurrent.BatchingExecutor$class.execute(BatchingExecutor.scala:106) [scala-library-2.11.7.jar:na]
        at scala.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:597) [scala-library-2.11.7.jar:na]
        at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) [scala-library-2.11.7.jar:na]
        at scala.concurrent.impl.Promise$KeptPromise.onComplete(Promise.scala:333) [scala-library-2.11.7.jar:na]
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:254) [scala-library-2.11.7.jar:na]
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:249) [scala-library-2.11.7.jar:na]
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [scala-library-2.11.7.jar:na]
        at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:40) [play_2.11-2.4.3.jar:2.4.3]
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) [akka-actor_2.11-2.3.13.jar:na]
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) [akka-actor_2.11-2.3.13.jar:na]
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.11.7.jar:na]
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.11.7.jar:na]
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.11.7.jar:na]
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.11.7.jar:na]

这是我的 build.sbt

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.7"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs,
  "uk.co.panaxiom" %% "play-jongo" % "0.9.0-jongo1.2",
  "org.mindrot" % "jbcrypt" % "0.3m",
  "be.objectify" %% "deadbolt-java" % "2.4.3"
)

这是我的 application.conf

play {
  crypto{
    secret = "/;=<kFhD6b]oMNMfNAQt7lqiaw<;u:>jiEFGeSiVd3i?PNL_:ZCI2>jTkywBPMYhhfQo"
  }
  i18n{
    langs = [ "en" ]
  }
  modules {
    enabled += be.objectify.deadbolt.java.DeadboltModule,
    enabled += modules.CustomDeadboltHook
  }
}
  deadbolt {
    java {
      # cache-user is set to false, otherwise it's not possible to mix deadbolt handler that do and don't have users in the template examples
      cache-user=false
    }
  }
playjongo.uri="mongodb://127.0.0.1:27017/play"
playjongo.gridfs.enabled=false
playjongo.defaultWriteConcern="SAFE"

奇怪的是,我得到了错误,但数据仍然更新到数据库中。但我认为数据已损坏,因为我无法使用锁舌处理数据。

我错过了什么吗?也许在配置中,或者我执行错误?

4

0 回答 0