Overriding default Redirect View in Spring Social
java, spring, spring-mvc, spring-social, twitter
Solution
Ok, I found the solution myself. Posting the answer for everyone, so that anyone struggling with the silly thing might be benefited:
Actually I had ConnectController configured in my Config & now the custom controller was stepping on that & hence it says already mapped. Removing the config from the config solves the problem.
In my case removing the following code:
<bean class="org.springframework.social.connect.web.ConnectController">
relies on by-type autowiring for the constructor-args
<property name="applicationUrl" value="${application.url}" />
</bean>
Problem
I'm trying to override the default behavior of Spring Social to redirect to "connect/{providerId}Connected" once connected to a provider (Twitter, Facebook etc). So I'm trying to override the default behavior by overriding the method protected java.lang.String connectedView(java.lang.String providerId) So I've subclassed ConnectController and tried overriding: ``` @Controller public class CustomConnectController extends ConnectController{ @Inject public CustomConnectController( ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository) { super(connectionFactoryLocator, connectionRepository); } @Override protected String connectedView(String providerId){ //Do some logic return "redirect:/foo/bar; } } ``` See documentation of the controller class: http://static.springsource.org/spring-social/docs/1.0.x/api/org/springframework/social/connect/web/ConnectController.html But I get the following error: Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'org.springframework.social.connect.web.ConnectController#0' bean method public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.connect(java.lang.String,org.springframework.web.context.request.NativeWebRequest) to {[/connect/{providerId}],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'customConnectController' bean method public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.connect(java.lang.String,org.springframework.web.context.request.NativeWebRequest) mapped. Can anyone please guide. My requirement is as follows: 1. After user connects social account (Twitter, Facebook etc) 2. Do some business logic 3. Redirect to /foo/bar page Please help.