Hi Sergey,

Actually, I want the opposite to happen in my case. I do not want the stacktrace to get included in the response. And at certain cases, hide the actual error altogether. An email to maintenance (me) would include the stacktrace. Mappers are enough for my needs right now.

Gabo

Sergey Beryozkin wrote:
Hi

Also, by default, custom Exceptions with no mappers are propogated to the
container which just replies 500. One can disable it by registering a
'org.apache.cxf.propogate.exception' = false jaxrs property, in which case
you'll get a message from XMLBinding containing thte stack trace. Gabo - if you're reading it - it may help in your case too

cheers, Sergey


Sam.Wang wrote:
Hi Eamonn:

Thanks your reply. You are right!
I have added a customized ExceptionMapper to JAXRSServerFactoryBean, and
it works fine. Thanks, Sam.


Eamonn Dwyer-2 wrote:
Hi Sam,
maybe you should be throwing a WebApplicationException rather than just
an Exception.

There is more information available at
http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-Exceptionhandling

I think if you want to throw an Exception you could register an Exception
Mapper to handle it for JaxRS

Regards
Eamonn


Date: Thu, 13 Aug 2009 02:49:05 -0700
From: [email protected]
To: [email protected]
Subject: How to get the exception response?


Hi ,
I used the JAXRSServerFactoryBean to publish REST service, but in the
client(javascript code), I can't get response info when server error
happening.

        @GET
        @Path("/customers/{id}/")
        public Customer getCustomer(@PathParam("id") String id) throws
Exception{
                if(true)
                        throw new Exception("Error!");

                long idNumber = Long.parseLong(id);
                Customer c = customers.get(idNumber);
                return c;
        }

In the web browser, I only can get the response code :

500 Internal Server Error
        
but the response info is null:

0 B

Can I output the error info/stack to client? and how?

Thanks!
Sam
--
View this message in context:
http://www.nabble.com/How-to-get-the-exception-response--tp24952068p24952068.html
Sent from the cxf-user mailing list archive at Nabble.com.

_________________________________________________________________
What can you do with the new Windows Live? Find out
http://www.microsoft.com/windows/windowslive/default.aspx


------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.55/2301 - Release Date: 08/13/09 18:16:00

Reply via email to