users@jersey.java.net

[Jersey] Re: Best way to diagnose a 400 error on POST

From: Jason Erickson <jason_at_jasonerickson.com>
Date: Mon, 13 Dec 2010 14:23:35 -0800

I managed to isolate just the code that should be unmarshalling the JSON in a unit test. The error I am getting there is: "javax.xml.bind.UnmarshalException: Unable to create an instance of com.factorlab.security.Party"

This is correct in that Party is an abstract class and what I really want is a particular concrete sub-class "Person", but how do I indicate that in natural JSON notation? Or am I going to need to write my one MessageBodyReader for this?

On Dec 13, 2010, at 1:40 AM, Paul Sandoz wrote:

> Hi Jason,
>
> Any error in the server side logs?
>
> Paul.
>
> On Dec 10, 2010, at 6:10 AM, Jason Erickson wrote:
>
>> Hi. I have a REST method defined thus:
>> @POST
>> @Consumes(MediaType.APPLICATION_JSON)
>> public Response addObservationSession(ObservationSession session, @Context UriInfo uriInfo) throws URISyntaxException
>> {
>> .. do some stuff
>> return Response.created(new URI("/" + session.getId())).build();
>> }
>>
>> This is giving me a 400 error when I call it. Clearly it doesn't like my JSON string, but it's hard for me to tell what's wrong with it (or if it's not the string, maybe it's the header or who knows). I can't put a breakpoint in my code because it never gets to my code. What's the best way to get a clue?
>