Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Invalid
    • Affects Version/s: 3.0.5
    • Fix Version/s: None
    • Component/s: Web
    • Labels:
      None

      Description

      When using the restTemplate.put, my request is sent to the server and executes properly, but the restTemplate throws this exception:

      org.springframework.web.client.ResourceAccessException: I/O error: http://localhost:8080/movie/update; nested exception is java.io.FileNotFoundException: http://localhost:8080/movie/update
      	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:453)
      	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401)
      	at org.springframework.web.client.RestTemplate.put(RestTemplate.java:327)
      ...
      Caused by: java.io.FileNotFoundException: http://localhost:8080/movie/update
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      	at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1368)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1362)
      	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1016)
      	at org.springframework.http.client.SimpleClientHttpResponse.getBody(SimpleClientHttpResponse.java:78)
      	at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:72)
      	at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486)
      	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443)
      ...
      Sep 19, 2011 7:08:56 PM org.springframework.web.client.RestTemplate handleResponseError
      WARNING: PUT request for "http://localhost:8080/movie/update" resulted in 404 (Not Found); invoking error handler
      Sep 19, 2011 7:08:56 PM org.springframework.web.client.RestTemplate handleResponseError
      WARNING: PUT request for "http://localhost:8080/movie/updateAll" resulted in 404 (Not Found); invoking error handler

      In my server log I see this output, notice the URI has an extra "/movie" in it, I did not pass that in.

      Sep 20, 2011 12:08:56 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
      WARNING: No mapping found for HTTP request with URI [/movie/movie/updateAll] in DispatcherServlet with name 'mdbAppServlet'

      I received this error on spring 3.0.5 and also tried 3.1.0.M2 and still received the error.

        Activity

        Hide
        rstoya05-aop Rossen Stoyanchev added a comment -

        Could you provide a test case that reproduces the problem? Ideally, follow the instructions and the project template here https://github.com/SpringSource/spring-framework-issues rather than creating everything from scratch and using attachments.

        Thanks

        Show
        rstoya05-aop Rossen Stoyanchev added a comment - Could you provide a test case that reproduces the problem? Ideally, follow the instructions and the project template here https://github.com/SpringSource/spring-framework-issues rather than creating everything from scratch and using attachments. Thanks
        Hide
        srgrodeon Steve Grodeon added a comment -

        I added test case https://github.com/srgrodeon/spring-framework-issues/tree/master/SPR-8711 hopefully I put it up right, I am new to github.

        Show
        srgrodeon Steve Grodeon added a comment - I added test case https://github.com/srgrodeon/spring-framework-issues/tree/master/SPR-8711 hopefully I put it up right, I am new to github.
        Hide
        rstoya05-aop Rossen Stoyanchev added a comment -

        Yes, you did it right. It looks like you were missing @ResponseBody on your controller method. This is the resulting output in the log file:

        2011-10-06 06:43:46,683 DEBUG [org.springframework.web.servlet.DispatcherServlet] - <DispatcherServlet with name 'appServlet' processing PUT request for [/SPR-8711/test/update]>
        2011-10-06 06:43:46,684 DEBUG [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapping [/test/update] to HandlerExecutionChain with handler [[email protected]] and 2 interceptors>
        2011-10-06 06:43:46,685 DEBUG [org.springframework.web.bind.annotation.support.HandlerMethodInvoker] - <Reading [org.springframework.web.issues.TestObject] as "application/json;charset=UTF-8" using [org.springf[email protected]246d12a9]>
        2011-10-06 06:43:46,689 DEBUG [org.springframework.web.bind.annotation.support.HandlerMethodInvoker] - <Invoking request handler method: public void org.springframework.web.issues.PutController.update(org.springframework.web.issues.TestObject)>
        data=data
        2011-10-06 06:43:46,689 DEBUG [org.springframework.web.servlet.DispatcherServlet] - <Rendering view [org.springframework.web.servlet.view.InternalResourceView: name 'test/update'; URL [test/update]] in DispatcherServlet with name 'appServlet'>
        2011-10-06 06:43:46,689 DEBUG [org.springframework.web.servlet.view.InternalResourceView] - <Forwarding to resource [test/update] in InternalResourceView 'test/update'>
        2011-10-06 06:43:46,690 DEBUG [org.springframework.web.servlet.DispatcherServlet] - <DispatcherServlet with name 'appServlet' processing PUT request for [/SPR-8711/test/test/update]>
        2011-10-06 06:43:46,690 WARN [org.springframework.web.servlet.PageNotFound] - <No mapping found for HTTP request with URI [/SPR-8711/test/test/update] in DispatcherServlet with name 'appServlet'>
        2011-10-06 06:43:46,690 DEBUG [org.springframework.web.servlet.DispatcherServlet] - <Successfully completed request>

        Notice that the method does get invoked but then since it doesn't have @ResponseBody, instead of writing to the reponse directly, view resolution is attempted and fails to find a view with the name "test/update". As a result the server returns a 404.

        Show
        rstoya05-aop Rossen Stoyanchev added a comment - Yes, you did it right. It looks like you were missing @ResponseBody on your controller method. This is the resulting output in the log file: 2011-10-06 06:43:46,683 DEBUG [org.springframework.web.servlet.DispatcherServlet] - <DispatcherServlet with name 'appServlet' processing PUT request for [/SPR-8711/test/update]> 2011-10-06 06:43:46,684 DEBUG [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapping [/test/update] to HandlerExecutionChain with handler [[email protected]] and 2 interceptors> 2011-10-06 06:43:46,685 DEBUG [org.springframework.web.bind.annotation.support.HandlerMethodInvoker] - <Reading [org.springframework.web.issues.TestObject] as "application/json;charset=UTF-8" using [org.springf[email protected]246d12a9]> 2011-10-06 06:43:46,689 DEBUG [org.springframework.web.bind.annotation.support.HandlerMethodInvoker] - <Invoking request handler method: public void org.springframework.web.issues.PutController.update(org.springframework.web.issues.TestObject)> data=data 2011-10-06 06:43:46,689 DEBUG [org.springframework.web.servlet.DispatcherServlet] - <Rendering view [org.springframework.web.servlet.view.InternalResourceView: name 'test/update'; URL [test/update]] in DispatcherServlet with name 'appServlet'> 2011-10-06 06:43:46,689 DEBUG [org.springframework.web.servlet.view.InternalResourceView] - <Forwarding to resource [test/update] in InternalResourceView 'test/update'> 2011-10-06 06:43:46,690 DEBUG [org.springframework.web.servlet.DispatcherServlet] - <DispatcherServlet with name 'appServlet' processing PUT request for [/SPR-8711/test/test/update]> 2011-10-06 06:43:46,690 WARN [org.springframework.web.servlet.PageNotFound] - <No mapping found for HTTP request with URI [/SPR-8711/test/test/update] in DispatcherServlet with name 'appServlet'> 2011-10-06 06:43:46,690 DEBUG [org.springframework.web.servlet.DispatcherServlet] - <Successfully completed request> Notice that the method does get invoked but then since it doesn't have @ResponseBody, instead of writing to the reponse directly, view resolution is attempted and fails to find a view with the name "test/update". As a result the server returns a 404.

          People

          • Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            srgrodeon Steve Grodeon
            Last updater:
            Trevor Marshall
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              6 years, 21 weeks, 3 days ago