Hello,
The following exception is being thrown whilst using the Apache Jersey
client. From what I've been able to find out, this is occurring because
there's a communications error in the PUT to my resource and the client
is automatically attempting to retry but can't because it doesn't think
that it can re-read the entity. My questions are, given that the entity
I'm trying to send is an instance of
com.sun.jersey.api.representation.Form, why is it being treated as
"unbuffered"? and what can I use instead?
Caused by: com.sun.jersey.api.client.ClientHandlerException:
org.apache.commons.httpclient.ProtocolException: Unbuffered entity
enclosing request can not be repeated.
at
com.sun.jersey.client.apache.ApacheHttpClientHandler.handle(ApacheHttpClientHandler.java:202)
at com.sun.jersey.api.client.Client.handle(Client.java:365)
at
com.sun.jersey.api.client.WebResource.handle(WebResource.java:556)
at
com.sun.jersey.api.client.WebResource.access$300(WebResource.java:68)
at
com.sun.jersey.api.client.WebResource$Builder.put(WebResource.java:466)
at com.myapp.services.MyMainBean.ejbTimeout(MyMainBean.java:225)
at sun.reflect.GeneratedMethodAccessor253.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at
com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at
com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at
com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at
com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:2824)
... 6 more
Caused by: org.apache.commons.httpclient.ProtocolException: Unbuffered
entity enclosing request can not be repeated.
at
org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:487)
at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at
com.sun.jersey.client.apache.ApacheHttpClientHandler.handle(ApacheHttpClientHandler.java:197)
... 18 more
I'm PUTing the resource using this code:
MultivaluedMap<String, String> formParams = new Form();
formParams.add("param1", param1);
WebResource resource =
restClient.resource(resourceUri).queryParam("request_id", requestId);
ClientResponse resp =
resource.entity(formParams).type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).put(ClientResponse.class);
Many thanks,
Steve