Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-8711

restTemplate gets 404 for PUT request

    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.

        Attachments

          Activity

            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, 42 weeks, 1 day ago