Error trying to use ReactiveMongo from securesocial plugin

124 views
Skip to first unread message

user123

unread,
Aug 20, 2013, 1:59:24 PM8/20/13
to reacti...@googlegroups.com
I want to get save/load my users from the database. I'm using already ReactiveMongo, in my Play app.

Most examples access the db from a controller. In order to get this working with securesocial, I'm modifying the InMemoryUserService sample from securesocial, which extends, play.api.Plugin, and not controller.

I started implementing it like this:

import play.api.Play.current
import scala.concurrent.ExecutionContext
import ExecutionContext.Implicits.global

class InMemoryUserService(application: Application) extends UserServicePlugin(application) {

  val db = ReactiveMongoPlugin.db
  val collection = db[JSONCollection]("users")

  //...
}

But I already get a mysterious error (stack overflow) in the console:

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.3]
at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:130) ~[play_2.10.jar:2.1.3]
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.3]
at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:130) ~[play_2.10.jar:2.1.3]
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.7.0_25]
at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:242) ~[na:1.7.0_25]
at java.io.File.exists(File.java:772) ~[na:1.7.0_25]
at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:1072) ~[na:1.7.0_25]
at sun.misc.URLClassPath$FileLoader.findResource(URLClassPath.java:1039) ~[na:1.7.0_25]
at sun.misc.URLClassPath$1.next(URLClassPath.java:226) ~[na:1.7.0_25]

In the webpage the stacktrace looks a bit different - although the message is also not very informative:

"An exception occurred during Plugin [service.InMemoryUserService] initialization"

But it points to the causing line:

  play.api.Application$class.plugin(Application.scala:235)
     play.api.DefaultApplication.plugin(Application.scala:383)
     play.modules.reactivemongo.ReactiveMongoPlugin$.current(ReactiveMongoPlugin.scala:79)
     play.modules.reactivemongo.ReactiveMongoPlugin$.db(ReactiveMongoPlugin.scala:76)
     service.InMemoryUserService.<init>(InMemoryUserService.scala:33)

which is:

  val db = ReactiveMongoPlugin.db


What's happening? Am I not supposed to access the db from this class? If not, how do I use Mongo to store my users with securesocial?

Thanks in advance.

Kiran Rohankar

unread,
Apr 7, 2014, 5:06:51 PM4/7/14
to reacti...@googlegroups.com
I am trying the same thing with play and secure social.I am getting the same error.
Did you get any solution for the same?

Stephane Godbillon

unread,
Apr 16, 2014, 2:48:25 AM4/16/14
to reacti...@googlegroups.com
Hi both,

Try to replace `val db = ReactiveMongoPlugin.db` by `def db = ReactiveMongoPlugin.db`. It may be a play-specific issue due to hot app reloading in development.

Cheers,

--
You received this message because you are subscribed to the Google Groups "ReactiveMongo - http://reactivemongo.org" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reactivemong...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages