Reputation: 664
I am trying to use Deadbolt in my Play+Scala application (2.5x). I added following into my build.sbt (Play 2.5x):
libraryDependencies += "be.objectify" %% "deadbolt-scala" % "2.5.1"
And in my conf/application.conf:
enabled += "be.objectify.deadbolt.scala.DeadboltModule"
After "sbt run" when I access the server, I immediately get this error:
play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors:
1) No implementation for be.objectify.deadbolt.scala.cache.HandlerCache was bound.
while locating be.objectify.deadbolt.scala.cache.HandlerCache
for parameter 1 at be.objectify.deadbolt.scala.ActionBuilders.<init>(ActionBuilders.scala:30)
at be.objectify.deadbolt.scala.DeadboltModule.bindings(DeadboltModule.scala:32):
Binding(class be.objectify.deadbolt.scala.ActionBuilders to self) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
2) No implementation for be.objectify.deadbolt.scala.cache.HandlerCache was bound.
while locating be.objectify.deadbolt.scala.cache.HandlerCache
for parameter 1 at be.objectify.deadbolt.scala.DeadboltActions.<init>(DeadboltActions.scala:34)
at be.objectify.deadbolt.scala.DeadboltModule.bindings(DeadboltModule.scala:30):
Binding(class be.objectify.deadbolt.scala.DeadboltActions to self) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
2 errors]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:180)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:131)
at scala.Option.map(Option.scala:146)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:131)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:129)
at scala.util.Success.flatMap(Try.scala:231)
There is no other code change I made. Why should it fail even though I have not yet wrote any line of code to use Deadbolt ?
Upvotes: 0
Views: 261
Reputation: 647
It doesn't work because it requires certain interfaces inplemented, and bound in DI. So you can't just drop in the dependency, and expect it to work.
You need to DI bind at least :
TemplateFailureListener HandlerCache DeadboltExecutionContextProvider
A working example is available at https://github.com/schaloner/deadbolt-2-scala-examples
Upvotes: 1