users@jersey.java.net

Exception-Handling null request

From: ZigZag <powerld_at_web.de>
Date: Tue, 10 Aug 2010 08:19:15 -0700 (PDT)

Hi,

i've a problem with the exception handling of null request. That means if my
service got a correct json object, everything works fine. But if i send a
null object to the service the client got a 500 (internal server error)
response. On the server side i got the error


    10.08.2010 16:53:48 com.sun.jersey.spi.container.ContainerResponse
mapMappableContainerException
    SCHWERWIEGEND: The RuntimeException could not be mapped to a response,
re-throwing to the
    HTTP container
    java.lang.IllegalStateException: reader must be on a START_ELEMENT
event, not a 8 event
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:352)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
        at
com.sun.jersey.json.impl.BaseJSONUnmarshaller.unmarshalJAXBElementFromJSON(BaseJSONUnmarshaller.java:103)


Sure, it make sence that the server can't unmarshal the json string to an
object because it's null, but now my question, is it possible to catch the
exception and to send a more detailed response?

   

    @POST
    @Path("receive")
    @Consumes("application/json")
    @Produces("application/json")
    public synchronized Response receiveAdress(Adress adress){
    
           .....
           return response;
    }

-- 
View this message in context: http://jersey.576304.n2.nabble.com/Exception-Handling-null-request-tp5393493p5393493.html
Sent from the Jersey mailing list archive at Nabble.com.