spring-attic / spring-social

Allows you to connect your applications with SaaS providers such as Facebook and Twitter.
http://projects.spring.io/spring-social
Apache License 2.0
619 stars 350 forks source link

405 Method not allowed: GET not supported #181

Closed Chumper closed 8 years ago

Chumper commented 9 years ago

Ok, i have included the following plugins:

    compile "org.springframework.social:spring-social-core:1.1.2.RELEASE"
    compile "org.springframework.social:spring-social-web:1.1.2.RELEASE"
    compile "org.springframework.social:spring-social-config:1.1.2.RELEASE"
    compile "org.springframework.social:spring-social-security:1.1.2.RELEASE"
    compile "org.springframework.social:spring-social-github:1.0.0.M4"

i am using spring boot 1.3.0.M5 my config looks like this:

@Configuration
@EnableSocial
class SocialConfig extends SocialConfigurerAdapter {

    @Override
    void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer,
                                Environment environment) {
//        connectionFactoryConfigurer.addConnectionFactory(
//                new GitHubConnectionFactory(
//                        environment.getProperty("config.oauth2.github.appId"),
//                        environment.getProperty("config.oauth2.github.appSecret")
//                )
//        )
    }

    @Override
    UserIdSource getUserIdSource() {
        return {
            return "anonymous"
        }
    }
}

if I want to see my connections, i get a 405

screen shot 2015-09-09 at 11 05 54

The log tells me this:

2015-09-09 10:58:42.055 TRACE 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Bound request context to thread: FirewalledRequest[ org.apache.catalina.connector.RequestFacade@440198c]
2015-09-09 10:58:42.055 DEBUG 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/connect/]
2015-09-09 10:58:42.057 TRACE 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping@5c7c237e] in DispatcherServlet with name 'dispatcherServlet'
2015-09-09 10:58:42.058 TRACE 5384 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : No handler mapping found for [/connect/]
2015-09-09 10:58:42.058 TRACE 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@1bf8c1cc] in DispatcherServlet with name 'dispatcherServlet'
2015-09-09 10:58:42.058 DEBUG 5384 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /connect/
2015-09-09 10:58:42.062 TRACE 5384 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Found 1 matching mapping(s) for [/connect/] : [{[/connect/],methods=[GET]}]
2015-09-09 10:58:42.062 DEBUG 5384 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public java.lang.String org.springframework.social.connect.web.ConnectController.connectionStatus(org.springframework.web.context.request.NativeWebRequest,org.springframework.ui.Model)]
2015-09-09 10:58:42.063 TRACE 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler adapter [org.springframework.data.rest.webmvc.RepositoryRestHandlerAdapter@634e6a70]
2015-09-09 10:58:42.063 TRACE 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter@6bb86bf4]
2015-09-09 10:58:42.063 DEBUG 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/connect/] is: -1
2015-09-09 10:58:42.068 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.RequestParamMethodArgumentResolver@53fca559] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.069 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.RequestParamMapMethodArgumentResolver@530e4f78] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.069 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.PathVariableMethodArgumentResolver@4769c291] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.069 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.PathVariableMapMethodArgumentResolver@69d1004c] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.069 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.MatrixVariableMethodArgumentResolver@74e006f7] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.069 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.MatrixVariableMapMethodArgumentResolver@3df26755] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.069 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor@495119a2] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.069 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor@3b833206] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.070 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.RequestPartMethodArgumentResolver@e5dda2d] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.070 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.RequestHeaderMethodArgumentResolver@2c6cdae2] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.070 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.RequestHeaderMapMethodArgumentResolver@52a57852] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.070 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.ServletCookieValueMethodArgumentResolver@18d4132e] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.070 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.ExpressionValueMethodArgumentResolver@5a5c4704] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.070 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.ServletRequestMethodArgumentResolver@62a97202] supports [interface org.springframework.web.context.request.NativeWebRequest]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.RequestParamMethodArgumentResolver@53fca559] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.RequestParamMapMethodArgumentResolver@530e4f78] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.PathVariableMethodArgumentResolver@4769c291] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.PathVariableMapMethodArgumentResolver@69d1004c] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.MatrixVariableMethodArgumentResolver@74e006f7] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.MatrixVariableMapMethodArgumentResolver@3df26755] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor@495119a2] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor@3b833206] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.RequestPartMethodArgumentResolver@e5dda2d] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.RequestHeaderMethodArgumentResolver@2c6cdae2] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.RequestHeaderMapMethodArgumentResolver@52a57852] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.ServletCookieValueMethodArgumentResolver@18d4132e] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.ExpressionValueMethodArgumentResolver@5a5c4704] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.ServletRequestMethodArgumentResolver@62a97202] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.ServletResponseMethodArgumentResolver@26cd111] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.071 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor@37fd8966] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.072 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.servlet.mvc.method.annotation.RedirectAttributesMethodArgumentResolver@42316ff0] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.072 TRACE 5384 --- [nio-8080-exec-1] s.HandlerMethodArgumentResolverComposite : Testing if argument resolver [org.springframework.web.method.annotation.ModelMethodProcessor@195c6869] supports [interface org.springframework.ui.Model]
2015-09-09 10:58:42.073 TRACE 5384 --- [nio-8080-exec-1] .w.s.m.m.a.ServletInvocableHandlerMethod : Invoking [ConnectController.connectionStatus] method with arguments [ServletWebRequest: uri=/connect/;client=0:0:0:0:0:0:0:1, {}]
2015-09-09 10:58:42.084 TRACE 5384 --- [nio-8080-exec-1] .w.s.m.m.a.ServletInvocableHandlerMethod : Method [connectionStatus] returned [connect/status]
2015-09-09 10:58:42.087 DEBUG 5384 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Requested media types are [text/html, application/xhtml+xml, image/webp, application/xml;q=0.9, */*;q=0.8] based on Accept header types and producible media types [*/*])
2015-09-09 10:58:42.087 DEBUG 5384 --- [nio-8080-exec-1] o.s.w.servlet.view.BeanNameViewResolver  : No matching bean found for view name 'connect/status'
2015-09-09 10:58:42.091 TRACE 5384 --- [nio-8080-exec-1] o.s.w.s.v.InternalResourceViewResolver   : Cached view [connect/status]
2015-09-09 10:58:42.091 DEBUG 5384 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Returning [org.springframework.web.servlet.view.InternalResourceView: name 'connect/status'; URL [connect/status]] based on requested media type 'text/html'
2015-09-09 10:58:42.091 DEBUG 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Rendering view [org.springframework.web.servlet.view.InternalResourceView: name 'connect/status'; URL [connect/status]] in DispatcherServlet with name 'dispatcherServlet'
2015-09-09 10:58:42.091 TRACE 5384 --- [nio-8080-exec-1] o.s.w.servlet.view.InternalResourceView  : Rendering view with name 'connect/status' with model {social_authorization_error=null, providerIds=[], connectionMap={}} and static attributes {}
2015-09-09 10:58:42.091 DEBUG 5384 --- [nio-8080-exec-1] o.s.w.servlet.view.InternalResourceView  : Removed model object 'social_authorization_error' from request in view with name 'connect/status'
2015-09-09 10:58:42.091 DEBUG 5384 --- [nio-8080-exec-1] o.s.w.servlet.view.InternalResourceView  : Added model object 'providerIds' of type [java.util.HashMap$KeySet] to request in view with name 'connect/status'
2015-09-09 10:58:42.091 DEBUG 5384 --- [nio-8080-exec-1] o.s.w.servlet.view.InternalResourceView  : Added model object 'connectionMap' of type [org.springframework.util.LinkedMultiValueMap] to request in view with name 'connect/status'
2015-09-09 10:58:42.092 DEBUG 5384 --- [nio-8080-exec-1] o.s.w.servlet.view.InternalResourceView  : Forwarding to resource [connect/status] in InternalResourceView 'connect/status'
2015-09-09 10:58:42.095 TRACE 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Bound request context to thread: FirewalledRequest[ FirewalledRequest[ org.apache.catalina.core.ApplicationHttpRequest@484f42a1]]
2015-09-09 10:58:42.095 DEBUG 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/connect/connect/status]
2015-09-09 10:58:42.095 TRACE 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping@5c7c237e] in DispatcherServlet with name 'dispatcherServlet'
2015-09-09 10:58:42.095 TRACE 5384 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : No handler mapping found for [/connect/connect/status]
2015-09-09 10:58:42.095 TRACE 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@1bf8c1cc] in DispatcherServlet with name 'dispatcherServlet'
2015-09-09 10:58:42.095 DEBUG 5384 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /connect/connect/status
2015-09-09 10:58:42.097 DEBUG 5384 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
2015-09-09 10:58:42.097 DEBUG 5384 --- [nio-8080-exec-1] .w.s.m.a.ResponseStatusExceptionResolver : Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
2015-09-09 10:58:42.097 DEBUG 5384 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
2015-09-09 10:58:42.097  WARN 5384 --- [nio-8080-exec-1] o.s.web.servlet.PageNotFound             : Request method 'GET' not supported
2015-09-09 10:58:42.098  WARN 5384 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Handler execution resulted in exception: Request method 'GET' not supported
2015-09-09 10:58:42.098 DEBUG 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2015-09-09 10:58:42.098 TRACE 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Cleared thread-bound request context: FirewalledRequest[ FirewalledRequest[ org.apache.catalina.core.ApplicationHttpRequest@484f42a1]]
2015-09-09 10:58:42.098 DEBUG 5384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Successfully completed request

So there is a request to connect/connect/status which has no handler obvious.

Did i configure something wrong? When I post to connect/github, so enabled github and have a valid id and key it will redirect me, so there is a template problem i guess.

Any solutions?

Edit: This also happens with spring boot 1.2.5.RELEASE

habuma commented 8 years ago

I'm not sure, given the information here. A couple of things to consider/try:

First, try making a request to /connect/status (without a trailing slash). See if that makes a difference.

If not, then can you provide a project that recreates this (not necessarily your real project...just a facsimile that exhibits this behavior will be fine) in GitHub?

mfaisalhyder commented 8 years ago

Kindly Post the Controller code of the class for which you are using RequestMapping(''/connect") may be you are using RequestMethod.DELETE/POST in that method which is getting called on /connect mapping, so it won't work for POST/PUT/DELETE calls you need to make panel then write its whole Ajax calls to see it actually working from browser, if you try typing in address bar then it is a GET request ,

@RestController @RequestMapping("/customer") public class CustomerController {

@RequestMapping(value="/delete/id/{id}",method={RequestMethod.GET,RequestMethod.DELETE}) public Map<String,String> deleteCustomerById( @PathVariable("id") String id){ mCustomerRepository.deleteById(id);

    Map<String,String> response = new HashMap<String,String>();
    response.put("report", "Customer removed");
    return response;
}

} this is how i am using Delete request to delete a document from MongoDB 192.168.0.100:8080/customer/delete/id/56e128c2475a426f50cf9303 and 'deleteById' is a simple void method method in my Repository class with @Param("id") to match the POJO.

There are three ways to test without banging your head why it is not working. 1- Make 'TEST' cases using Spring MVC features for static data test. 2- Make a complete panel then write Ajax calls for requests. 3- Make a simple java project to test it statically.

Hope i help somebody.

govindJeeChoueby commented 5 years ago

Im also facing the same problem org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported]

@RequestMapping(value ="/Insertdata",method = RequestMethod.POST) public String putData(@RequestBody UserAccount userac) { try { jdbcTemplate.execute("INSERT INTO UserAccount(ID,Name,age) VALUES (01,'Kishri Jee',16)"); } but for retrieve its working fine

Please help me

Prati-987 commented 3 years ago

http://localhost:8080/signup-action

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Feb 26 16:41:33 IST 2021 There was an unexpected error (type=Method Not Allowed, status=405). Request method 'GET' not supported

This is controller @RestController @RequestMapping(value = "/signup-action", method = RequestMethod.POST) public ModelAndView doFreeTrailAction(@Valid @ModelAttribute("form") InitialDetail initialDetail, BindingResult bindingResult, HttpServletRequest request) throws IOException {

    logger.info("Performing sign up action for..." + initialDetail);

    Cookie cookie = WebUtils.getCookie(request, "sourceId");
    String sourceId = null;
    if (cookie != null) {
        sourceId = cookie.getValue();
    }

so please tell me if anybody knows