Http response is closed

Let’s assume we got a Http response

    Response response =

and now we want to read the body of the response as a String

    String responseBody = response.readEntity(String.class)

or as an object

    User user = response.readEntity(User.class)

Resteasy. Response is closed. bufferEntity

Response is closed exception

When we try to read the response body (response.readEntity(..)) next time we will get an exception java.lang.IllegalStateException: RESTEASY003765: Response is closed

java.lang.IllegalStateException: RESTEASY003765: Response is closed.

    at org.jboss.resteasy.specimpl.BuiltResponse.abortIfClosed(
    at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.abortIfClosed(
    at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(
    at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(


All you need to do to prevent that is just to call response.bufferEntity(..) before reading the response body.

    String responseBody = response.readEntity(String.class);
    User user = response.readEntity(User.class);

So now with response.bufferEntity(..) we can read the response body multiple times.

You may also find these posts interesting: