I'm developing a sample application that will post feeds to Facebook periodically using Spring's Task Scheduler. I downloaded the latest spring-social-showcase project and extracted the relevant parts for my needs. I also setup a login mechanism using Spring Security 3.1 RC1's in-memory user-service.
I prefer to work via XML configuration than a Java-based configuration. In order for my application to access the currently authenticated user, I have to follow the following:
The sample spring-social-showcase project uses a Java-based configuration, which is good IF there was also an XML-based configuration demo. Since most Spring users are used to XML-based, I just think that it's best that we include both options in the project. That's my first recommendation.Code:<bean id="connectionRepository" factory-method="createConnectionRepository" factory-bean="usersConnectionRepository" scope="request"> <constructor-arg value="#{request.userPrincipal.name}" /> </bean> Source: http://static.springsource.org/spring-social/docs/1.0.x/reference/html/connecting.html
However, my real issue is when using the Expression Language "#{request.userPrincipal.name}". I have to setup my bean to use a "scope="request" which is understandable. However when I run my application, I get the following error:
I'm aware of adding the <aop:scoped-proxy> but I'm wondering why it's never used or mentioned in the documentation (See http://static.springsource.org/sprin...onnecting.html). If it's not used, then it means it's not needed? But my application will not run without it.java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? ...
So I added <aop:scoped-proxy>.
I now have the following:
I'm able to login and get authenticated via Spring Security. However this still fails when I try to login to Facebook. Here's the simplified stacktrace:Code:<bean id="connectionRepository" factory-method="createConnectionRepository" factory-bean="usersConnectionRepository" scope="request"> <constructor-arg value="#{request.userPrincipal.name}" /> <aop:scoped-proxy /> </bean>
I have CGLIB on my classpath. I use Maven. To resolve the issue, I had to modify the aop-proxy element with:Code:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.connectionRepository' org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class org.springframework.social.connect.jdbc.JdbcConnectionRepository]: Common causes of this problem include using a final class or a non-visible class; java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
Then my application works as expected. I understand what proxy-target-class="false" does. It's clearly stated in the docs.Code:<aop:scoped-proxy proxy-target-class="false"/>
I'm using the latest jars for Spring Social, Spring Security, and Spring Core:
Here's a snippet of my Maven properties section:
I'm wondering why I need to go such process when the documentation (Spring Social) isn't even using such? I might be missing a simple solution here? Thanks a lotCode:<properties> <springCoreVersion>3.1.0.M1</springCoreVersion> <springSocialVersion>1.0.0.M3</springSocialVersion> <springSecurityVersion>3.1.0.RC1</springSecurityVersion> </properties>


Reply With Quote
