users@jersey.java.net

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

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Wed, 16 Dec 2009 15:15:56 +0100

On Tue, Dec 15, 2009 at 11:20:52AM -0800, cgswtsu78 wrote:
>
> 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.

It is strange, for the post, it should look for a writer, not reader.

>
> When I do a GET request using the WebResource everything works fine. Also

Could you please file an issue and attach a simple reproducible test case?
If you do not want to make your code publicly available, would it be possible
to send your project directly to me (japod at sun.com), so that i can have a look?

Thanks,

~Jakub


> 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.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
http://blogs.sun.com/japod