customizing secureSocial for play framework and spring (Dependency injection)

530 Views Asked by At

I'm using secure social version 2.0.13 for Play 2.0.6 with play and spring. I downloaded project template from type safe tutorials and just added secure social to it using it's guide from http://securesocial.ws/guide/getting-started.html Then I replaced the login and Template with my version because I needed login page with no signup . So I copied the login and it's Template to my custom package and just removed the sign up tag from it. The problem is when I start my application and request a url, I am confronted with this error :

[error] play - Cannot invoke the action, eventually got an error: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [securesocial.core.java.SecureSocial$Secured] is defined[error] application -

! @6gfok11pe - Internal server error, for (GET) [/] ->
play.api.Application$$anon$1: Execution exception[[NoSuchBeanDefinitionException: No qualifying bean of type [securesocial.core.java.SecureSocial$Secured] is defined]]
        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.applyOrE  lse(PlayDefaultUpstreamHandler.scala:261) [play_2.10.jar:2.2.0]
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No q    ualifying bean of type [securesocial.core.java.SecureSocial$Secured] is defined
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListablBeanFactory.java:296) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1125) ~[spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]
        at AbstractGlobal.getControllerInstance(AbstractGlobal.java:29) ~[oul_2.10.jar:na]
        at Global.getControllerInstance(Global.java:27) ~[classes/:na]
        at play.core.j.JavaGlobalSettingsAdapter.getControllerInstance(JavaGlobalSettingsAdapter.scala:46) ~[play_2.10.jar:2.2.0]
        at play.core.j.JavaAction$$anonfun$8.apply(JavaAction.scala:80) ~[play_2.10.jar:2.2.0]

However if I don't use spring (using no Global and no getControllerInstance) the sample works just fine! Please help me using secure social and spring together. thanks.

1

There are 1 best solutions below

0
On

Add this line to your Global.java in Global.onStart():

ctx.register(SecureSocial.Secured.class);