org.springframework.web.client.ResourceAccessException: I/O error on PUT request for "http://SomeService/update-status/56333d18e4b098563b66bda4?status=Deleted":com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException; nested exception is java.io.IOException: com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException

Spring JIRA | Paul Crockett | 1 year ago
  1. 0

    {code:java} restTemplate.put("http://SomeService/update-status/{0}?status={1}", null, id, status); {code} In this case I am calling a service to update a status field on an object, specified by an id in the URL path and the new status as a query string parameter. The Javadoc for RestOperations.put indicates that null is a valid, but when I do this an exception is thrown, shown below. The same occurs if I use postForEntity instead of put. The doc for postForEntity also states that null is valid as the request body. {code:java} org.springframework.web.client.ResourceAccessException: I/O error on PUT request for "http://SomeService/update-status/56333d18e4b098563b66bda4?status=Deleted":com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException; nested exception is java.io.IOException: com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:580) ~[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:530) ~[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.web.client.RestTemplate.put(RestTemplate.java:382) ~[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] ...etc... Caused by: java.io.IOException: com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException at org.springframework.cloud.netflix.ribbon.RibbonClientHttpRequestFactory$RibbonHttpRequest.executeInternal(RibbonClientHttpRequestFactory.java:125) ~[spring-cloud-netflix-core-1.0.3.RELEASE.jar:1.0.3.RELEASE] at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:569) ~[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] ... 112 common frames omitted Caused by: com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:184) ~[jersey-apache-client4-1.11.jar:1.11] at com.sun.jersey.api.client.Client.handle(Client.java:648) ~[jersey-client-1.11.jar:1.11] at com.sun.jersey.api.client.WebResource.handle(WebResource.java:670) ~[jersey-client-1.11.jar:1.11] at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.11.jar:1.11] at com.sun.jersey.api.client.WebResource$Builder.put(WebResource.java:533) ~[jersey-client-1.11.jar:1.11] at com.netflix.niws.client.http.RestClient.execute(RestClient.java:624) ~[ribbon-httpclient-2.0.2.jar:2.0.2] at com.netflix.niws.client.http.RestClient.execute(RestClient.java:527) ~[ribbon-httpclient-2.0.2.jar:2.0.2] at org.springframework.cloud.netflix.ribbon.RibbonClientHttpRequestFactory$RibbonHttpRequest.executeInternal(RibbonClientHttpRequestFactory.java:122) ~[spring-cloud-netflix-core-1.0.3.RELEASE.jar:1.0.3.RELEASE] ... 114 common frames omitted Caused by: org.apache.http.client.ClientProtocolException: null at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:867) ~[httpclient-4.3.4.jar:4.3.4] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:115) ~[httpclient-4.3.4.jar:4.3.4] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) ~[httpclient-4.3.4.jar:4.3.4] at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:170) ~[jersey-apache-client4-1.11.jar:1.11] ... 121 common frames omitted Caused by: org.apache.http.ProtocolException: Content-Length header already present at org.apache.http.protocol.RequestContent.process(RequestContent.java:95) ~[httpcore-4.3.2.jar:4.3.2] at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:131) ~[httpcore-4.3.2.jar:4.3.2] at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:165) ~[httpcore-4.3.2.jar:4.3.2] at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:485) ~[httpclient-4.3.4.jar:4.3.4] at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) ~[httpclient-4.3.4.jar:4.3.4] {code} The problem is easily worked around by passing an empty string instead of null, but as the doc explicitly states that null is permitted, then this seems like a bug. Initial investigation suggests that HttpCore does not expect the Content-Length header to be already set, and HttpEntityRequestCallback.doWithRequest is setting it when the body is null, hence the exception.

    Spring JIRA | 1 year ago | Paul Crockett
    org.springframework.web.client.ResourceAccessException: I/O error on PUT request for "http://SomeService/update-status/56333d18e4b098563b66bda4?status=Deleted":com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException; nested exception is java.io.IOException: com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException
  2. 0

    {code:java} restTemplate.put("http://SomeService/update-status/{0}?status={1}", null, id, status); {code} In this case I am calling a service to update a status field on an object, specified by an id in the URL path and the new status as a query string parameter. The Javadoc for RestOperations.put indicates that null is a valid, but when I do this an exception is thrown, shown below. The same occurs if I use postForEntity instead of put. The doc for postForEntity also states that null is valid as the request body. {code:java} org.springframework.web.client.ResourceAccessException: I/O error on PUT request for "http://SomeService/update-status/56333d18e4b098563b66bda4?status=Deleted":com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException; nested exception is java.io.IOException: com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:580) ~[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:530) ~[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.web.client.RestTemplate.put(RestTemplate.java:382) ~[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] ...etc... Caused by: java.io.IOException: com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException at org.springframework.cloud.netflix.ribbon.RibbonClientHttpRequestFactory$RibbonHttpRequest.executeInternal(RibbonClientHttpRequestFactory.java:125) ~[spring-cloud-netflix-core-1.0.3.RELEASE.jar:1.0.3.RELEASE] at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:569) ~[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] ... 112 common frames omitted Caused by: com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:184) ~[jersey-apache-client4-1.11.jar:1.11] at com.sun.jersey.api.client.Client.handle(Client.java:648) ~[jersey-client-1.11.jar:1.11] at com.sun.jersey.api.client.WebResource.handle(WebResource.java:670) ~[jersey-client-1.11.jar:1.11] at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.11.jar:1.11] at com.sun.jersey.api.client.WebResource$Builder.put(WebResource.java:533) ~[jersey-client-1.11.jar:1.11] at com.netflix.niws.client.http.RestClient.execute(RestClient.java:624) ~[ribbon-httpclient-2.0.2.jar:2.0.2] at com.netflix.niws.client.http.RestClient.execute(RestClient.java:527) ~[ribbon-httpclient-2.0.2.jar:2.0.2] at org.springframework.cloud.netflix.ribbon.RibbonClientHttpRequestFactory$RibbonHttpRequest.executeInternal(RibbonClientHttpRequestFactory.java:122) ~[spring-cloud-netflix-core-1.0.3.RELEASE.jar:1.0.3.RELEASE] ... 114 common frames omitted Caused by: org.apache.http.client.ClientProtocolException: null at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:867) ~[httpclient-4.3.4.jar:4.3.4] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:115) ~[httpclient-4.3.4.jar:4.3.4] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) ~[httpclient-4.3.4.jar:4.3.4] at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:170) ~[jersey-apache-client4-1.11.jar:1.11] ... 121 common frames omitted Caused by: org.apache.http.ProtocolException: Content-Length header already present at org.apache.http.protocol.RequestContent.process(RequestContent.java:95) ~[httpcore-4.3.2.jar:4.3.2] at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:131) ~[httpcore-4.3.2.jar:4.3.2] at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:165) ~[httpcore-4.3.2.jar:4.3.2] at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:485) ~[httpclient-4.3.4.jar:4.3.4] at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) ~[httpclient-4.3.4.jar:4.3.4] {code} The problem is easily worked around by passing an empty string instead of null, but as the doc explicitly states that null is permitted, then this seems like a bug. Initial investigation suggests that HttpCore does not expect the Content-Length header to be already set, and HttpEntityRequestCallback.doWithRequest is setting it when the body is null, hence the exception.

    Spring JIRA | 1 year ago | Paul Crockett
    org.springframework.web.client.ResourceAccessException: I/O error on PUT request for "http://SomeService/update-status/56333d18e4b098563b66bda4?status=Deleted":com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException; nested exception is java.io.IOException: com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException
  3. 0

    When using the restTemplate.put, my request is sent to the server and executes properly, but the restTemplate throws this exception: {code} 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 {code} In my server log I see this output, notice the URI has an extra "/movie" in it, I did not pass that in. {code}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' {code} I received this error on spring 3.0.5 and also tried 3.1.0.M2 and still received the error.

    Spring JIRA | 5 years ago | Steve Grodeon
    org.springframework.web.client.ResourceAccessException: I/O error: http://localhost:8080/movie/update; nested exception is java.io.FileNotFoundException: http://localhost:8080/movie/update
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    When using the restTemplate.put, my request is sent to the server and executes properly, but the restTemplate throws this exception: {code} 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 {code} In my server log I see this output, notice the URI has an extra "/movie" in it, I did not pass that in. {code}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' {code} I received this error on spring 3.0.5 and also tried 3.1.0.M2 and still received the error.

    Spring JIRA | 5 years ago | Steve Grodeon
    org.springframework.web.client.ResourceAccessException: I/O error: http://localhost:8080/movie/update; nested exception is java.io.FileNotFoundException: http://localhost:8080/movie/update
  6. 0

    Netflix Ribbon and Hystrix Timeout

    Stack Overflow | 3 months ago | Arun
    org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://USERASSOCIATIONS-V1/user/v1/internal/userassociationstatus?cardholderid=123&usercontextid=222&role=ACCOUNT": com.sun.jersey.api.client.ClientHandlerException: java.net.SocketTimeoutException: Read timed out; nested exception is java.io.IOException: com.sun.jersey.api.client.ClientHandlerException: java.net.SocketTimeoutException: Read timed out

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.web.client.ResourceAccessException

      I/O error on PUT request for "http://SomeService/update-status/56333d18e4b098563b66bda4?status=Deleted":com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException; nested exception is java.io.IOException: com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException

      at org.springframework.web.client.RestTemplate.doExecute()
    2. Spring
      RestTemplate.put
      1. org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:580)[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      2. org.springframework.web.client.RestTemplate.execute(RestTemplate.java:530)[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      3. org.springframework.web.client.RestTemplate.put(RestTemplate.java:382)[spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      3 frames