HI sergey, We are upgrading CXF version 2.7.7 to 3.1.8 and facing the below
issue.
AUDIT:2017-08-15 11:31:11.047:localhost-startStop-1:"Caused by
javax.ws.rs.ProcessingException: java.lang.IllegalStateException: Entity is
not available
at
org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:1141)
at org.apache.cxf.jaxrs.client.WebClient.doResponse(WebClient.java:1110)
at
org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1035)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:892)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:863)
at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:413)
at
com.walmart.platform.soa.client.RestClient.invoke(RestClient.java:261)
... 78 more
I have gone through this ticket
https://issues.apache.org/jira/browse/CXF-5144 which you mentioned that Set
this property: "response.stream.auto.close" to true. This is done even
though we are getting the same issue.
When i debug the code, in WebClient.invoke method this exception is occured.
protected Response handleResponse(Message outMessage, Class<?>
responseClass, Type genericType) {
try {
ResponseBuilder rb = setResponseBuilder(outMessage,
outMessage.getExchange());
Response currentResponse = rb.clone().build();
((ResponseImpl)currentResponse).setOutMessage(outMessage);
Object entity = readBody(currentResponse, outMessage,
responseClass, genericType,
new Annotation[]{});
if (entity == null) {
int status = currentResponse.getStatus();
if (status >= 400) {
entity = currentResponse.getEntity();
}
}
rb = JAXRSUtils.fromResponse(currentResponse);
rb.entity(entity instanceof Response
? ((Response)entity).getEntity() : entity);
Response r = rb.build();
getState().setResponse(r);
((ResponseImpl)r).setOutMessage(outMessage);
return r;
} catch (Throwable ex) {
throw (ex instanceof ProcessingException) ?
(ProcessingException)ex
: new
ProcessingException(ex);
} finally {
ClientProviderFactory.getInstance(outMessage).clearThreadLocalProxies();
}
}
public static ResponseBuilder fromResponse(Response response) {
ResponseBuilder rb = toResponseBuilder(response.getStatus());
* rb.entity(response.getEntity());
* for (Map.Entry<String, List<Object>> entry :
response.getMetadata().entrySet()) {
List values = entry.getValue();
for (Object value : values) {
rb.header(entry.getKey(), value);
}
}
return rb;
}
* rb.entity(response.getEntity());
* seems like , entity is null in ResponseBuilder rb from the fromResponse
method.
Please let me know, what could be the solution to fix this issue?
--
View this message in context:
http://cxf.547215.n5.nabble.com/Closing-of-WebClient-and-Response-objects-tp5748134p5782716.html
Sent from the cxf-user mailing list archive at Nabble.com.