Announcement Announcement Module
Collapse
No announcement yet.
404 when trying to access connection page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 404 when trying to access connection page

    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!

  • #2
    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)?

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment


        • #5
          Hello,

          404 erroer means that page is not exist ....

          Comment


          • #6
            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?

            Comment


            • #7
              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

              Comment


              • #8
                Originally posted by dikie.aditya View Post
                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?

                Comment


                • #9
                  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.

                  Comment


                  • #10
                    404 no mapping in dispatcher

                    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

                    PHP Code:
                    @Configuration
                    public class SocialConfig {

                        @
                    Resource(name="socialProperties")
                        private 
                    Map<StringMap<StringUserAccount>> 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().createConnectionRepository(
                                    
                    authentication.getName());
                        }

                        @
                    Bean
                        
                    @Scope(value "request"proxyMode ScopedProxyMode.INTERFACES)
                        public 
                    Facebook facebook() {
                            
                    Connection<Facebookfacebook connectionRepository()
                                    .
                    findPrimaryConnection(Facebook.class);
                            return 
                    facebook != null facebook.getApi() : new FacebookTemplate();
                        }

                        @
                    Bean
                        
                    @Scope(value "request"proxyMode ScopedProxyMode.INTERFACES)
                        public 
                    Twitter twitter() {
                            
                    Connection<Twittertwitter 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

                    PHP Code:
                    <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.

                    Comment


                    • #11
                      Hmm, I'm working in a module style (core/web). Moving SocialConfig to the web project resolved the issue.

                      Comment

                      Working...
                      X