0

我正在开发一个网络应用程序,我正在使用 zentasks 示例应用程序用于用户身份验证的方式,因此登录完成后,用户名存储在会话中。现在我正在尝试使用 DeadBolt 2 插件进行授权部分。基本上我已经将示例 DeadBolt 2 应用程序合并到我自己的应用程序中。唯一的区别是我使用 2.sql 来引导默认数据而不是 Global.java(并且角色名称与 foo & bar 不同)。现在登录后,当我尝试访问由 @SubjectPresent 注释的控制器方法时,我得到 NullPointerException 并带有以下堆栈跟踪:

[error] play - Cannot invoke the action, eventually got an error: java.lang.NullPointerException
[error] application - 

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

play.api.Application$$anon$1: Execution exception[[NullPointerException: null]]
at play.api.Application$class.handleError(Application.scala:293) ~[play_2.10.jar:2.2.0]
at play.api.DefaultApplication.handleError(Application.scala:399) ~[play_2.10.jar:2.2.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) ~[play_2.10.jar:2.2.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) ~[play_2.10.jar:2.2.0]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2.applyOrElse(PlayDefaultUpstreamHandler.scala:261) ~[play_2.10.jar:2.2.0]
Caused by: java.lang.NullPointerException: null
at be.objectify.deadbolt.java.actions.SubjectPresentAction.execute(SubjectPresentAction.java:56) ~[deadbolt-java_2.10-2.2-RC3.jar:2.2-RC3]
at be.objectify.deadbolt.java.actions.AbstractDeadboltAction.call(AbstractDeadboltAction.java:97) ~[deadbolt-java_2.10-2.2-RC3.jar:2.2-RC3]
at play.core.j.JavaAction$$anon$3.apply(JavaAction.scala:91) ~[play_2.10.jar:2.2.0]
at play.core.j.JavaAction$$anon$3.apply(JavaAction.scala:90) ~[play_2.10.jar:2.2.0]
at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.scala:82) ~[play_2.10.jar:2.2.0]
at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.scala:82) ~[play_2.10.jar:2.2.0]

关于哪里出错的任何想法?

编辑: 我切换到RC4,这次我使用 @Restrict 得到了这个错误

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

play.api.Application$$anon$1: Execution exception[[NullPointerException: null]]
at play.api.Application$class.handleError(Application.scala:293) ~[play_2.10.jar:2.2.0]
at play.api.DefaultApplication.handleError(Application.scala:399) [play_2.10.jar:2.2.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) [play_2.10.jar:2.2.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) [play_2.10.jar:2.2.0]
at scala.Option.map(Option.scala:145) [scala-library.jar:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2.applyOrElse(PlayDefaultUpstreamHandler.scala:261) [play_2.10.jar:2.2.0]

    Caused by: java.lang.NullPointerException: null
at be.objectify.deadbolt.java.actions.AbstractRestrictiveAction.execute(AbstractRestrictiveAction.java:47) ~[deadbolt-java_2.10-2.2-RC4.jar:2.2-RC4]
at be.objectify.deadbolt.java.actions.AbstractDeadboltAction.call(AbstractDeadboltAction.java:119) ~[deadbolt-java_2.10-2.2-RC4.jar:2.2-RC4]
at play.core.j.JavaAction$$anon$3.apply(JavaAction.scala:91) ~[play_2.10.jar:2.2.0]
at play.core.j.JavaAction$$anon$3.apply(JavaAction.scala:90) ~[play_2.10.jar:2.2.0]
at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.scala:82) ~[play_2.10.jar:2.2.0]
at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.scala:82) ~[play_2.10.jar:2.2.0]

2.2-RC1 仍然工作得很好,我使用 play 2.2.0 没有问题。

4

1 回答 1

2

我已经解决了这个问题并发布了一个新版本——切换到 2.2-RC4 版本,你应该没问题。

"be.objectify" %% "deadbolt-java" % "2.2-RC4"
于 2014-01-29T07:22:35.263 回答