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.

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.

Is there any issue when the response type of a method is File?

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