如果我尝试在securesocial in memory 服务中使用play-reactive mongo,我会得到一个错误。
import play.api.Play.current
/**
* A Sample In Memory user service in Scala
*
* IMPORTANT: This is just a sample and not suitable for a production environment since
* it stores everything in memory.
*/
class InMemoryUserService(application: Application) extends UserServicePlugin(application) {
private var users = Map[String, Identity]()
private var tokens = Map[String, Token]()
[...]
但它似乎在控制器内工作正常:
import play.api.Play.current
object Application extends Controller with securesocial.core.SecureSocial {
val db = ReactiveMongoPlugin.db
lazy val collections = db("persons")
[...]
是否可以在控制器之外使用播放上下文?
我得到的错误是尝试访问使用所述类抛出错误的资源时:
! @6dl5aj9h3 - Internal server error, for (GET) [/login] ->
play.api.PlayException: Cannot load plugin[An exception occurred during Plugin [service.InMemoryUserService] initialization]
at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:149) ~[play_2.10.jar:2.1.0]
at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:130) ~[play_2.10.jar:2.1.0]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) ~[scala-library.jar:na]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) ~[scala-library.jar:na]
at scala.collection.immutable.List.foreach(List.scala:309) ~[scala-library.jar:na]
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244) ~[scala-library.jar:na]
Caused by: play.api.PlayException: Cannot load plugin[An exception occurred during Plugin [service.InMemoryUserService] initialization]
at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:149) ~[play_2.10.jar:2.1.0]
at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:130) ~[play_2.10.jar:2.1.0]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) ~[scala-library.jar:na]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) ~[scala-library.jar:na]
at scala.collection.immutable.List.foreach(List.scala:309) ~[scala-library.jar:na]
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244) ~[scala-library.jar:na]
[repeats a lot]
Caused by: play.api.PlayException: Cannot load plugin[An exception occurred during Plugin [service.InMemoryUserService] initialization]
at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:149) ~[play_2.10.jar:2.1.0]
at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:130) ~[play_2.10.jar:2.1.0]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) ~[scala-library.jar:na]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) ~[scala-library.jar:na]
at scala.collection.immutable.List.foreach(List.scala:309) ~[scala-library.jar:na]
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244) ~[scala-library.jar:na]
java.lang.StackOverflowError: null
at java.io.UnixFileSystem.getBooleanAttributes0(Native Method) ~[na:1.6.0_43]
at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:228) ~[na:1.6.0_43]
at java.io.File.exists(File.java:733) ~[na:1.6.0_43]
at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:999) ~[na:1.6.0_43]
at sun.misc.URLClassPath$FileLoader.findResource(URLClassPath.java:966) ~[na:1.6.0_43]
at sun.misc.URLClassPath$1.next(URLClassPath.java:196) ~[na:1.6.0_43]