On Dec 13, 2010, at 11:23 PM, Jason Erickson wrote:
> 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?
>
How are you generating the JSON?
In the XML equivalent there should be an "xsi:type" attribute that
declares the type and gives JAXB enough clues on what to do. That
information should also be present in the JSON.
Paul.
> 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?
>>
>