org.springframework.web.client.ResourceAccessException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • When using spring template to do a POST request, sometimes there is an org.springframework.web.client.ResourceAccessException , caused by a java.io.EOFException. my research results are pretty clear: its a "bug" in androids http client stuff. i found some workarround on StackOverflow that suggests using another requestfactory for spring rest tempalte. so i implemented a requestfactory using OkHttp. (see the gist in referenced URL) as i didn't wanted to have this in the org.springframework classpath i also had to make a Request and a Response class. all classes are based on your SimpleXXX variants. Here is the full stacktrace: A runtime exception was thrown while executing code in a background task org.springframework.web.client.ResourceAccessException: I/O error: null; nested exception is java.io.EOFException at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:491) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:439) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:415) at org.test.service.rest.RestApi_.sendGreeting(RestApi_.java:91) at org.test.activities.TestActivity.send(TestActivity.java:89) at org.test.activities.TestActivity_.access$101(TestActivity_.java:29) at org.test.activities.TestActivity_$4.execute(TestActivity_.java:160) at org.androidannotations.api.BackgroundExecutor$Task.run(BackgroundExecutor.java:302) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390) at java.util.concurrent.FutureTask.run(FutureTask.java:234) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856) Caused by: java.io.EOFException at libcore.io.Streams.readAsciiLine(Streams.java:203) at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573) at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821) at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283) at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495) at org.springframework.http.client.SimpleClientHttpResponse.getRawStatusCode(SimpleClientHttpResponse.java:54) at org.springframework.http.client.SimpleClientHttpResponse.getStatusCode(SimpleClientHttpResponse.java:80) at org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:46) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:477) ... 14 more
    via by Kay Janssen,
  • When using spring template to do a POST request, sometimes there is an org.springframework.web.client.ResourceAccessException , caused by a java.io.EOFException. my research results are pretty clear: its a "bug" in androids http client stuff. i found some workarround on StackOverflow that suggests using another requestfactory for spring rest tempalte. so i implemented a requestfactory using OkHttp. (see the gist in referenced URL) as i didn't wanted to have this in the org.springframework classpath i also had to make a Request and a Response class. all classes are based on your SimpleXXX variants. Here is the full stacktrace: A runtime exception was thrown while executing code in a background task org.springframework.web.client.ResourceAccessException: I/O error: null; nested exception is java.io.EOFException at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:491) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:439) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:415) at org.test.service.rest.RestApi_.sendGreeting(RestApi_.java:91) at org.test.activities.TestActivity.send(TestActivity.java:89) at org.test.activities.TestActivity_.access$101(TestActivity_.java:29) at org.test.activities.TestActivity_$4.execute(TestActivity_.java:160) at org.androidannotations.api.BackgroundExecutor$Task.run(BackgroundExecutor.java:302) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390) at java.util.concurrent.FutureTask.run(FutureTask.java:234) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856) Caused by: java.io.EOFException at libcore.io.Streams.readAsciiLine(Streams.java:203) at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573) at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821) at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283) at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495) at org.springframework.http.client.SimpleClientHttpResponse.getRawStatusCode(SimpleClientHttpResponse.java:54) at org.springframework.http.client.SimpleClientHttpResponse.getStatusCode(SimpleClientHttpResponse.java:80) at org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:46) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:477) ... 14 more
    via by Kay Janssen,
  • Phonegap camera.getPicture issues with upload
    via Stack Overflow by Zigson
    ,
  • 加载图片报错
    via GitHub by 7312013787
    ,
    • org.springframework.web.client.ResourceAccessException: I/O error: null; nested exception is java.io.EOFException at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:491) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:439) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:415) at org.test.service.rest.RestApi_.sendGreeting(RestApi_.java:91) at org.test.activities.TestActivity.send(TestActivity.java:89) at org.test.activities.TestActivity_.access$101(TestActivity_.java:29) at org.test.activities.TestActivity_$4.execute(TestActivity_.java:160) at org.androidannotations.api.BackgroundExecutor$Task.run(BackgroundExecutor.java:302) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390) at java.util.concurrent.FutureTask.run(FutureTask.java:234) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856) Caused by: java.io.EOFException at libcore.io.Streams.readAsciiLine(Streams.java:203) at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573) at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821) at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283) at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495) at org.springframework.http.client.SimpleClientHttpResponse.getRawStatusCode(SimpleClientHttpResponse.java:54) at org.springframework.http.client.SimpleClientHttpResponse.getStatusCode(SimpleClientHttpResponse.java:80) at org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:46) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:477) ... 14 more

    Users with the same issue

    bayukresnobayukresno
    7 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    danleyb2Interinteldanleyb2Interintel
    4 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    sagarsagar
    1 times, last one,
    2 more bugmates