Hi

On Thu, Dec 30, 2010 at 2:14 AM, ssen <[email protected]> wrote:

>
> I have a resource method as follows that streams file content.
>
> @Produces({"application/octet-stream", "application/json"})
> public class Foo {
> ..
>  @GET
>  public File getReport(...)
>
> When there is a specific exception thrown from the application layer, I
> need
> to send back a java object and a 404 response code encoded in JSON format.
>
> I tried adding an exception mapper and I see the toResponse method of the
> mapper getting invoked when
> the exception is thrown from the resource.
>
> But the client is receiving a HTTP 500 response code and the exception
> content is not traveling back to the client.
>
> How can I debug this?
>
> I traced to JAXRSInvoker.invoke and see that the Response that is generated
> from the exception mapper is added to the MessageContentsList. But somehow,
> the content is getting dropped during the response.
>
>
Can you please add a breakpoint in JAXRSOutInterceptor.handleMessage() ?
This should let you see if the custom Response entity has been written
out...It seems like no MessageBodyWriter has been found for the custom
content and (per the spec) 500 is returned in this case - it should also be
logged....


> When I throw a generic exception, it gets propagated back encoded in
> text/html and response code 500. But I would like to return a specific
> response code and the JSON object.
>
>
What happens in this case is that if no ExceptionMapper has been found then
the exception is propagated (per the spec) to the container - and usually
will be wrapped in a ServletException (or similar) and can be caught by
filters if needed...


> Is there any issue when the response type of a method is File?
>
> The response type should not affect the way the exceptions are handled...

Hope it helps, Sergey

We are using version 2.2.10.
>
> Thanks for any help,
> Shantanu Sen
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/JAX-RS-Custom-Exception-not-getting-progagated-tp3322045p3322045.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Reply via email to