users@jersey.java.net

[Jersey] Using Jersey to return JSON when doing a POST

From: cgswtsu78 <cgray_at_proofpoint.com>
Date: Tue, 15 Dec 2009 11:20:52 -0800 (PST)

Hello,

I'm trying to post to a jersey resource using the content type of
MediaType.APPLICATION_JSON AND I'm getting an error: SEVERE:
com.sun.jersey.api.client.ClientHandlerException: A message body reader for
Java type, class
com.proofpoint.resources.chartsvcs.entities.ChartSpecification, and MIME
media type, application/json, was not found.

When I do a GET request using the WebResource everything works fine. Also
when doing a GET via the URL it works fine. Just the POST isn't working. Is
there something I need to do with the ChartSpecification object?

Client class:
Client client = Client.create();
WebResource webResource =
client.resource("http://localhost:8080/ChartWebWiz/jersey/chartsvcs/");
ClientResponse response =
webResource.path("topspamsenderchart").type(MediaType.APPLICATION_JSON).post(ClientResponse.class,
chartSpec);

web service method:
@POST
@Path("/topspamsenderchart")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ImageDetails getTopSpamSenderChart(ChartSpecification chartSpec)
throws Exception{

//method logic here
ImageDetails imageDetails = new ImageDetails();

return imageDetails;
}

Class causing issues:
@XmlRootElement(name="ChartSpecification")
public class ChartSpecification implements Serializable{
        
}


-- 
View this message in context: http://n2.nabble.com/Using-Jersey-to-return-JSON-when-doing-a-POST-tp4171710p4171710.html
Sent from the Jersey mailing list archive at Nabble.com.