users@jersey.java.net

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

From: Jason Erickson <jason.h.erickson_at_gmail.com>
Date: Mon, 13 Dec 2010 12:15:10 -0800

Not really. I turned on tracing, but the only relevant thing in the log is this:
1 < X-Jersey-Trace-013: matched message body reader: class com.factorlab.observations.domain.ObservationSession, "application/json" -> com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$App_at_52ed6f9
1 < X-Jersey-Trace-014: mapped exception to response: javax.ws.rs.WebApplicationException_at_6ff530ab -> 400

This is relevant, but not very interesting as it doesn't tell me anything I didn't already know. Again, if I just wanted to unit test the JSON marshalling and unmarshalling, how would I go about doing that? I mean, outside the scope of the whole application server.

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?
>