View Full Version : 404 when trying to access connection page
sherlock
Mar 10th, 2011, 04:59 AM
Hi all!
I tried to integrate spring social into an existing project following the example spring-social-showcase. But when I try to access the connection page (e.g. /connect/twitter) I receive a 404 error:
RequestURI=/connect/connect/twitterConnect NOT_FOUND
Is the second "connect" folder an error based in misconfiguration or is this the correct path?
The server log says:
No mapping found for HTTP request with URI [/connect/connect/twitterConnect] in DispatcherServlet with name 'social'
so the request seems to arrive at the correct DispatcherServlet...
thx in advance!
habuma
Mar 10th, 2011, 07:34 AM
From the looks of it, you make it to ConnectController, but then there's some trouble resolving the view whose name is "connect/twitterConnect".
Comparing your code with Spring Social Showcase (https://github.com/SpringSource/spring-social-samples), have you configured a view resolver such as InternalResourceViewResolver? Do you have a corresponding JSP (/WEB-INF/views/twitterConnect.jsp)?
sherlock
Mar 12th, 2011, 05:50 AM
Thx a lot for your reply. I missed the two lines in the docs that describe the connect pages. Thought the controller would provide them.
habuma
Mar 13th, 2011, 02:29 PM
As of right now, yes, you'll have to create your own views. That said, awhile back I was pondering the idea of configuring ConnectController is "auto-view mode" where it'd provide a baseline view--not all that different conceptually from the login page that Spring Security's <http auto-config="true"> gives you. It'd be a simple (and probably aesthetically unpleasant) connect/connected page, but it would be a starting point that you could expand on to fit your app's look-n-feel.
At this point, it's just a random idea...but I've gone ahead and created an issue in Jira (https://jira.springsource.org/browse/SOCIAL-119) to track it.
bigapplecard
Mar 16th, 2011, 10:46 PM
Hello,
404 erroer means that page is not exist ....
sherlock
Mar 17th, 2011, 08:17 AM
But isn't the structure itself with one connect/connected page per service rather a starting point? An application that uses multiple services would probably use an aggregated view for all services, wouldn't it?
dikie.aditya
Jun 8th, 2011, 06:41 AM
Hi, I've similar problem, but in my case it's when performing form submit connecting to twitter.
here are my form code:
<form action="<c:url value="/connect/twitter" />" method="POST">
<button type="submit"><img src="<c:url value='/images/social/twitter/connect-with-twitter.png'/>" /></button>
</form>
and the error:
No mapping found for HTTP request with URI [/myapp/connect/twitter] in DispatcherServlet
habuma
Jun 8th, 2011, 08:40 AM
No mapping found for HTTP request with URI [/myapp/connect/twitter] in DispatcherServlet
How are you arriving at the page with this form on it? With a GET /myapp/connect/twitter? If so, then I'm a bit confused how ConnectController would be handling the GET request, but not the POST request. ConnectController should be able to handle both GET and POST requests to that same URL (the GET should display the page with the form on it, the POST should handle that form submission).
But if you are going to that page through some other means, then could it be that you don't have ConnectController configured correctly?
dikie.aditya
Jun 8th, 2011, 12:08 PM
Sorry I finally got it fix by changing the form action url to: <c:url value="/app/connect/twitter" />. It turn out that the DispatcherServlet is mapped to the /app/* url pattern in the web.xml
Thanks for the reply.
mschipperheyn
Jul 13th, 2011, 09:40 AM
Hi,
I'm using spring 3.0.5
I get this message
No mapping found for HTTP request with URI [/myapp/connect/twitter] in DispatcherServlet with name 'dispatcher'
The controllers from spring social are not automatically included in the dispatcher-servlet. How to handle this best?
My SocialConfig is like so
@Configuration
public class SocialConfig {
@Resource(name="socialProperties")
private Map<String, Map<String, UserAccount>> environment;
@Autowired
private SocialUserDao jpaTemplate;
@Bean
@Scope(value="singleton", proxyMode=ScopedProxyMode.INTERFACES)
public ConnectionFactoryLocator connectionFactoryLocator() {
ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
registry.addConnectionFactory(new FacebookConnectionFactory(
environment.get("mysite").get("facebook").getUserId(),
environment.get("mysite").get("facebook").getPassword()));
registry.addConnectionFactory(new TwitterConnectionFactory(
environment.get("mysite").get("twitter").getUserId(),
environment.get("mysite").get("twitter").getPassword()));
return registry;
}
@Bean
@Scope(value = "singleton", proxyMode = ScopedProxyMode.INTERFACES)
public UsersConnectionRepository usersConnectionRepository() {
return new JPAUsersConnectionRepository(jpaTemplate,
connectionFactoryLocator(), Encryptors.noOpText());
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public ConnectionRepository connectionRepository() {
Authentication authentication = SecurityContextHolder.getContext()
.getAuthentication();
if (authentication == null) {
throw new IllegalStateException(
"Unable to get a ConnectionRepository: no user signed in");
}
return usersConnectionRepository().createConnectionReposi tory(
authentication.getName());
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Facebook facebook() {
Connection<Facebook> facebook = connectionRepository()
.findPrimaryConnection(Facebook.class);
return facebook != null ? facebook.getApi() : new FacebookTemplate();
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Twitter twitter() {
Connection<Twitter> twitter = connectionRepository()
.findPrimaryConnection(Twitter.class);
return twitter != null ? twitter.getApi() : new TwitterTemplate();
}
@Bean
public ConnectController connectController() {
ConnectController connectController = new ConnectController(
connectionFactoryLocator(), connectionRepository());
return connectController;
}
@Bean
public ProviderSignInController providerSignInController() {
return new ProviderSignInController(connectionFactoryLocator( ),
usersConnectionRepository(), new SimpleSigninAdapter());
}
If I add component scanning to dispatcher servlet
<context:component-scan
base-package="org.springframework.social" />
I get an error because it wants to autowire JPAConnectionRepository based on a no-args constructor which isn't there.
mschipperheyn
Jul 13th, 2011, 10:13 AM
Hmm, I'm working in a module style (core/web). Moving SocialConfig to the web project resolved the issue.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.