com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: Error writing request body to server

Java.net JIRA | joven | 6 years ago
  1. 0

    [JERSEY-633] Cannot PUT to a WebResource after GETting it - Java.net JIRA

    java.net | 1 year ago
    com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: Error writing request body to server
  2. 0

    If I GET a WebResource and read from the entity input stream until the end and then try to POST or PUT to the same resource, the second operation immediately fails with the following exception stack. If I do not read the InputStream to the end, the PUT succeeds fine. I wrote up and included a test case that is attached. com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: Error writing request body to server at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:131) at com.sun.jersey.api.client.Client.handle(Client.java:629) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:601) at com.sun.jersey.api.client.WebResource.put(WebResource.java:211) at jersey.GetPutTest.testGetFollowedByPut(GetPutTest.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41) at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:220) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102) at org.apache.maven.surefire.Surefire.run(Surefire.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021) Caused by: java.io.IOException: Error writing request body to server at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(HttpURLConnection.java:2802) at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:2785) at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:90) at com.sun.jersey.core.util.ReaderWriter.writeTo(ReaderWriter.java:115) at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:76) at com.sun.jersey.core.impl.provider.entity.FileProvider.writeTo(FileProvider.java:103) at com.sun.jersey.core.impl.provider.entity.FileProvider.writeTo(FileProvider.java:64) at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:311) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:181) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:129) ... 32 more

    Java.net JIRA | 6 years ago | joven
    com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: Error writing request body to server
  3. 0

    If I GET a WebResource and read from the entity input stream until the end and then try to POST or PUT to the same resource, the second operation immediately fails with the following exception stack. If I do not read the InputStream to the end, the PUT succeeds fine. I wrote up and included a test case that is attached. com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: Error writing request body to server at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:131) at com.sun.jersey.api.client.Client.handle(Client.java:629) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:601) at com.sun.jersey.api.client.WebResource.put(WebResource.java:211) at jersey.GetPutTest.testGetFollowedByPut(GetPutTest.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41) at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:220) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102) at org.apache.maven.surefire.Surefire.run(Surefire.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021) Caused by: java.io.IOException: Error writing request body to server at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(HttpURLConnection.java:2802) at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:2785) at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:90) at com.sun.jersey.core.util.ReaderWriter.writeTo(ReaderWriter.java:115) at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:76) at com.sun.jersey.core.impl.provider.entity.FileProvider.writeTo(FileProvider.java:103) at com.sun.jersey.core.impl.provider.entity.FileProvider.writeTo(FileProvider.java:64) at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:311) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:181) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:129) ... 32 more

    Java.net JIRA | 6 years ago | joven
    com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: Error writing request body to server
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Failed tests preventing build: BatchRestAPITest exceptions

    GitHub | 4 years ago | sheymann
    com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: Error writing request body to server
  6. 0

    "IOException: Error writing request body to server" when uploading to S3

    Google Groups | 6 years ago | Martin Grotzke
    org.jclouds.http.HttpResponseException: error after writing 159744/1772194 bytes to PUT https://jclouds-test.s3.amazonaws.com/main-testimg.png HTTP/1.1 connecting to PUT https://jclouds-test.s3.amazonaws.com/main-testimg.png HTTP/1.1

    9 unregistered visitors
    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. java.io.IOException

      Error writing request body to server

      at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError()
    2. Java RT
      HttpURLConnection$StreamingOutputStream.write
      1. sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(HttpURLConnection.java:2802)
      2. sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:2785)
      2 frames
    3. jersey-client
      CommittingOutputStream.write
      1. com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:90)
      1 frame
    4. jersey-core
      FileProvider.writeTo
      1. com.sun.jersey.core.util.ReaderWriter.writeTo(ReaderWriter.java:115)
      2. com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:76)
      3. com.sun.jersey.core.impl.provider.entity.FileProvider.writeTo(FileProvider.java:103)
      4. com.sun.jersey.core.impl.provider.entity.FileProvider.writeTo(FileProvider.java:64)
      4 frames
    5. jersey-client
      WebResource.put
      1. com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:311)
      2. com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:181)
      3. com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:129)
      4. com.sun.jersey.api.client.Client.handle(Client.java:629)
      5. com.sun.jersey.api.client.WebResource.handle(WebResource.java:601)
      6. com.sun.jersey.api.client.WebResource.put(WebResource.java:211)
      6 frames
    6. jersey
      GetPutTest.testGetFollowedByPut
      1. jersey.GetPutTest.testGetFollowedByPut(GetPutTest.java:40)
      1 frame
    7. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    8. JUnit
      ParentRunner.run
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      5. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      6. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
      8. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
      9. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
      10. org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
      11. org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
      12. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      13. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      14. org.junit.runners.ParentRunner.run(ParentRunner.java:220)
      14 frames
    9. JUnit4 Provider
      JUnit4TestSet.execute
      1. org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
      1 frame
    10. SureFire
      Surefire.run
      1. org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)
      2. org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)
      3. org.apache.maven.surefire.Surefire.run(Surefire.java:180)
      3 frames
    11. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    12. SureFire
      SurefireBooter.main
      1. org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
      2. org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
      2 frames