users@jersey.java.net

Re: Exception mappers on marshalling exceptions

From: Andrew Ochsner <aochsner_at_cs.stanford.edu>
Date: Mon, 27 Apr 2009 16:43:17 -0500

Actually it could even be that all NPE don't get mapped by the
ExceptionMapper<Throwable> Would that make sense?

On Mon, Apr 27, 2009 at 1:50 PM, Andrew Ochsner <aochsner_at_cs.stanford.edu>wrote:

> Hello:
>
> I am noticing that when there is an exception in the Jersey framework code,
> specifically when marshalling json into an object (via jaxb) throws a
> NullPointerException, that the exception mappers never get called to convert
> that exception into a proper response. I have an exception mapper that maps
> all Throwable exceptions into 500 errors but it only passes the
> exception.getMessage() in the body rather than the full stack trace. In
> these exceptions I'm seeing the full stack traces which is leading my down
> this thinking.
>
> I scanned the jsr311 and it states:
> When a resource class or provider method throws an exception, the
> JAX-RS runtime will attempt to map the exception to a suitable HTTP response
> - see section 3.3.4<https://jsr311.dev.java.net/nonav/releases/1.0/spec/spec3.html#x3-280003.3.4>.
> An application can supply exception mapping providers to customize this
> mapping.
>
> To me that sounds like when a provider (in this case the jaxbjson
> marshaller using natural) throws an exception, that Jersey should be mapping
> that via the exception mappers.
>
> I can probably write a quick unit test to try to replicate this, but just
> thought I'd throw it on the mailing list to see if I'm completely wrong
> first.
>
> Thanks again
> Andy O
>