I am trying to send a generic list to a jersey servlet using put method, using GenericEntity. I have seen a lot of examples requesting a generic list, but none of them putting it.
So the code on my server is:
@PUT
@Produces(MediaType.TEXT_HTML)
public String doPutHtml(GenericType<List<SystemInfo>> systemInfoList) {
System.out.println(systemInfoList.toString());
return "OK";
}
And the code on the client sending the put request:
WebResource ws;
Configuration conf = ConfigurationFactory.getConfigurationFactory()
.getConfiguration();
Client client = Client.create();
ws = client.resource("http://" + conf.getDatacenterURL() + ":"+ conf.getDatacenterPort() + "/services/systemInfo");
GenericEntity entity = new GenericEntity<List<SystemInfo>>(systemInfoList) {};
String response = ws.accept(MediaType.TEXT_HTML).type(MediaType.APPLICATION_XML).put(String.class, entity);
When I run the client code, I get this exception:
com.sun.jersey.api.client.ClientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class java.util.ArrayList, and MIME media type, application/octet-stream, was not found
So my question would be, is it possible to send a generic list this way? In case this is not possible, are there any alternatives?