Closed reynirh closed 10 years ago
Play-Authenticate requires play-cache. If you have no cache plugin loaded, the cache will return null and you'll get this issue.
@smola if you check out the ticket https://github.com/joscha/play-authenticate/issues/134#issuecomment-30080484 , I do exactly what is recommended there, to fix a build problem. The build problem is fixed, so there for I must have a version of play-cache. Also it seems accessing play-cache is not throwing the NPE, but accessing the object returned from the cache.
@reynirh Yes. It's ok to add that dependency exclusion to prevent other packages pulling the wrong version of play-cache. But you still need play-cache (just the correct version). So check that you have cache
in your build file. For example, in build.sbt
:
libraryDependencies ++= Seq(cache, ...)
or in Build.scala
:
val appDependencies = Seq(cache ....)
If the problem persists after ensuring cache plugin is loaded, there might be another problem related to cookies. But let's see first if it's just the cache plugin problem.
I am getting the same error and I have, I believe, all the cache dependencies setup correctly like so:
val appDependencies = Seq(
javaCore, javaJdbc, javaEbean, cache,
"be.objectify" %% "deadbolt-java" % "2.2-RC2" exclude("com.typesafe.play", "play-cache_2.10"),
"be.objectify" %% "deadbolt-scala" % "2.2-RC2" exclude("com.typesafe.play", "play-cache_2.10"),
"com.feth" %% "play-authenticate" % "0.5.2-SNAPSHOT",
"postgresql" % "postgresql" % "9.1-901.jdbc4",
"commons-io" % "commons-io" % "2.4",
"commons-collections" % "commons-collections" % "3.2.1",
"joda-time" % "joda-time" % "2.3",
"org.owasp.antisamy" % "antisamy" % "1.4.4"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
resolvers += Resolver.url("Objectify Play Repository (release)", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("Objectify Play Repository (snapshot)", url("http://schaloner.github.com/snapshots/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-easymail (release)", url("http://joscha.github.com/play-easymail/repo/releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-easymail (snapshot)", url("http://joscha.github.com/play-easymail/repo/snapshots/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-authenticate (release)", url("http://joscha.github.com/play-authenticate/repo/releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-authenticate (snapshot)", url("http://joscha.github.com/play-authenticate/repo/snapshots/"))(Resolver.ivyStylePatterns)
)
I started to get this problem again in a setup where cache should be properly set up. I'm looking into the issue again.
Can you check if the problem persists with deadbolt-2.2.1-RC1
and not excluding the cache dependency? See: https://github.com/schaloner/deadbolt-2/issues/41
made the change, but now I am getting a different NPE after trying to authenticate:
play.api.Application$$anon$1: Execution exception[[NullPointerException: null]]
at play.api.Application$class.handleError(Application.scala:293) ~[play_2.10.jar:2.2.1]
at play.api.DefaultApplication.handleError(Application.scala:399) [play_2.10.jar:2.2.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) [play_2.10.jar:2.2.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) [play_2.10.jar:2.2.1]
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.1]
Caused by: java.lang.NullPointerException: null
at be.objectify.deadbolt.java.actions.AbstractRestrictiveAction.execute(AbstractRestrictiveAction.java:47) ~[deadbolt-java_2.10-2.2.1-RC1.jar:2.2.1-RC1]
at be.objectify.deadbolt.java.actions.AbstractDeadboltAction.call(AbstractDeadboltAction.java:119) ~[deadbolt-java_2.10-2.2.1-RC1.jar:2.2.1-RC1]
at play.core.j.JavaAction$$anon$3.apply(JavaAction.scala:91) ~[play_2.10.jar:2.2.1]
at play.core.j.JavaAction$$anon$3.apply(JavaAction.scala:90) ~[play_2.10.jar:2.2.1]
at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.scala:82) ~[play_2.10.jar:2.2.1]
at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.scala:82) ~[play_2.10.jar:2.2.1]
just changing the cache library dependency in build.sbt fixed the problem for me. I'm not getting the above NPE. @razorman8669 perhaps you have to run play clean-all
@reynirh, Running clean-all doesnt solve the NPE. not sure what is causing it yet...
The NPE is because null
handling in deadbolt2 changed slightly. See here https://github.com/schaloner/deadbolt-2/issues/41 for an easy fix.
the change fixed the issue. Thanks @joscha!
I've been updating my play project to 2.2.1 and just added a dependency exclusion for play-cache as described in https://github.com/joscha/play-authenticate/issues/134#issuecomment-30080484
Now the project builds, and seems to work up to the point of authentication where it fails with the following NPE: