You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gabo Manuel <km...@solegysystems.com> on 2009/02/12 11:11:24 UTC

[JAX-RS] Fault handling

Hi All,

I was just wondering if there is a possibility to acquire the actual 
Exception object, and maybe even replace it with another Exception 
through interceptors.

I was already able to change the response code (400 or 500) depending on 
whether the exception was a checked exception or not. I would however, 
prefer to be able to automatically notify some people for the unchecked 
exceptions. I tried printing all of the available content formats 
(message.getContentFormats()) to no avail.

Again, thanks in advance.

Gabo

Re: [JAX-RS] Fault handling

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Sergey,

I checked your ExceptionMapper. I'm not able to find that much 
difference other than I do some email notifications before returning the 
response object. :'( Would me using the snapshot got anything to do with it?

I got lost somewhere after this:

                writer.writeTo(responseObj, targetType, 
invoked.getGenericReturnType(),
                               invoked != null ? 
invoked.getAnnotations() : new Annotation[]{},
                               responseType,
                               response.getMetadata(),
                               out);

Would it be possible that this might have something to do with it:

javax.xml.transform.Result

I'm not really sure... I'll try to investigate further

Gabo

Sergey Beryozkin wrote:
> Hi Gabo
>
> I've updated one of the tests to show that an exception mapper can 
> report a text/plain message and no Result tags are added. Have a look 
> please at [1]
>
> here's the trace :
> *****************************
> HTTP/1.1 500 Internal Server Error
> Content-Type: text/plain
> Content-Length: 28
> Server: Jetty(6.1.11)
>
> No book found at all : 12345
> *****************************
>> > Is it possible to specify a custom provider from an ExceptionMapper 
>> implementation
>
> No, ExceptionMapper is a provider itself
>
>>  I was hoping to avoid the chain-abort work-around.
>
> I thought you removed the chain-abort work-around ?
>
> I'm sorry if I'm missing something. Obviously, those gremlin <Result> 
> tags are added somewhere, but I just don't see at the moment where. Is 
> there any chance you can debug the code a bit, starting from 
> JAXRSOutInterceptor ?
>
> Thanks, Sergey
>
> [1] 
> https://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookExceptionMapper.java 
>
>

Re: [JAX-RS] Fault handling

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabo

I've updated one of the tests to show that an exception mapper can report a text/plain message and no Result tags are added. Have a 
look please at [1]

here's the trace :
*****************************
HTTP/1.1 500 Internal Server Error
Content-Type: text/plain
Content-Length: 28
Server: Jetty(6.1.11)

No book found at all : 12345
*****************************
> > Is it possible to specify a custom provider from an ExceptionMapper implementation

No, ExceptionMapper is a provider itself

>  I was hoping to avoid the chain-abort work-around.

I thought you removed the chain-abort work-around ?

I'm sorry if I'm missing something. Obviously, those gremlin <Result> tags are added somewhere, but I just don't see at the moment 
where. Is there any chance you can debug the code a bit, starting from JAXRSOutInterceptor ?

Thanks, Sergey

[1] https://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookExceptionMapper.java

----- Original Message ----- 
From: "Gabo Manuel" <km...@solegysystems.com>
To: <us...@cxf.apache.org>
Sent: Wednesday, February 18, 2009 5:20 AM
Subject: Re: [JAX-RS] Fault handling


> Hi Sergey,
>
> Is it possible to specify a custom provider from an ExceptionMapper implementation? Or maybe a work around to remove the tags? I 
> was hoping to avoid the chain-abort work-around.
>
> Again, my thanks.
>
> Gabo
>
> Sergey Beryozkin wrote:
>> Hi Gabo
>>
>> Many thanks for creating the JIRAs.
>> ExceptionMappers are not CXF interceptors, they can be categorized as
>> JAXRS providers only. I'm still unclear at all as to where such Result
>> tags may come from - needs to be investigated indeed. It looks like
>> text_plain responses are wrapped ?
>> Cheers, Sergey 


Re: [JAX-RS] Fault handling

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Sergey,

Is it possible to specify a custom provider from an ExceptionMapper 
implementation? Or maybe a work around to remove the tags? I was hoping 
to avoid the chain-abort work-around.

Again, my thanks.

Gabo

Sergey Beryozkin wrote:
> Hi Gabo
>
> Many thanks for creating the JIRAs.
> ExceptionMappers are not CXF interceptors, they can be categorized as
> JAXRS providers only. I'm still unclear at all as to where such Result
> tags may come from - needs to be investigated indeed. It looks like
> text_plain responses are wrapped ?  
>
> Cheers, Sergey 
>   

RE: [JAX-RS] Fault handling

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabo

Many thanks for creating the JIRAs.
ExceptionMappers are not CXF interceptors, they can be categorized as
JAXRS providers only. I'm still unclear at all as to where such Result
tags may come from - needs to be investigated indeed. It looks like
text_plain responses are wrapped ?  

Cheers, Sergey 


-----Original Message-----
From: Gabo Manuel [mailto:kmanuel@solegysystems.com] 
Sent: 17 February 2009 11:43
To: users@cxf.apache.org
Subject: Re: [JAX-RS] Fault handling

Hi Sergey,

Thanks for the update.

> If you could create a JIRA and attach a sample interceptor and a
sample
> service class then it would help a lot and ensure the issue is
tracked.

https://issues.apache.org/jira/browse/CXF-2045
 - this is for the headers being lost

https://issues.apache.org/jira/browse/CXF-2046
 - this is for the result tag. Sorry, I forgot to adjust the level to
minor.

> Another issue was that Result prefixes were added if you used the CXF
> custom interceptor. I'm wondering, was it caused by the fact that the
> chain was aborted (as a workaround around the issue of headers being
> lost)?

The abort of the chain has been removed as per previous post. I am now 
using a ResponseHandler implementation to change the headers. But the 
behavior remains the same, i.e. the Result tag is still there. Also, I 
am assuming that the ExceptionMapper implementation is categorized as a 
custom interceptor. We could rule out the chain abort now. :)

> By the way, MultivaluedMap has Lists as values, so if you do prefer to
> reuse the code which deals with Lists then you just use
> MultivaluedMap.put(), add() is a utility method which creates a List
if
> it's not there...

I didn't notice that. Will adjust my code. :)

Again, my thanks.

Gabo

Sergey Beryozkin wrote:
> Hi Gabo
>
> So it does look like Result prefixes are added by the outbound chain
> somewhere. 
>
> I'm sorry I didn't investigate the issue with custom headers being
lost
> when added in a CXF out interceptor - but now that you posted some
code
> in the other email I will try to reproduce the problem. 
>
> If you could create a JIRA and attach a sample interceptor and a
sample
> service class then it would help a lot and ensure the issue is
tracked.
> I'd like to get it fixed as it's important that when JAXWS and JAXRS
is
> combined then a single CXF interceptor can be shared to do some custom
> header post-processing.
>
> Another issue was that Result prefixes were added if you used the CXF
> custom interceptor. I'm wondering, was it caused by the fact that the
> chain was aborted (as a workaround around the issue of headers being
> lost)?
>
> By the way, MultivaluedMap has Lists as values, so if you do prefer to
> reuse the code which deals with Lists then you just use
> MultivaluedMap.put(), add() is a utility method which creates a List
if
> it's not there...
>
> Thanks, Sergey
>
> -----Original Message-----
> From: Gabo Manuel [mailto:kmanuel@solegysystems.com] 
> Sent: 17 February 2009 10:51
> To: users@cxf.apache.org
> Subject: Re: [JAX-RS] Fault handling
>
> Hi Sergey,
>
> I have replaced the CXFInterceptor with a ResponseHandler 
> implementation. So no chain-abort now. Body of the handleResponse is
as 
> follows:
>
>         MultivaluedMap<String, Object> map = response.getMetadata();
>         map.add("Authentication-Info", 
> "nextnonce=\""+RestHandlerUtility.generateNonce(base_path)+"\"");
>         logger.debug("out message headers: " + map);
>         logger.info("response: " + response.getEntity());
>
> As of this point, the entity still does not contain the Result tag
>
> Again, my thanks.
>
> Gabo
>   

Re: [JAX-RS] Fault handling

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Sergey,

Thanks for the update.

> If you could create a JIRA and attach a sample interceptor and a sample
> service class then it would help a lot and ensure the issue is tracked.

https://issues.apache.org/jira/browse/CXF-2045
 - this is for the headers being lost

https://issues.apache.org/jira/browse/CXF-2046
 - this is for the result tag. Sorry, I forgot to adjust the level to minor.

> Another issue was that Result prefixes were added if you used the CXF
> custom interceptor. I'm wondering, was it caused by the fact that the
> chain was aborted (as a workaround around the issue of headers being
> lost)?

The abort of the chain has been removed as per previous post. I am now 
using a ResponseHandler implementation to change the headers. But the 
behavior remains the same, i.e. the Result tag is still there. Also, I 
am assuming that the ExceptionMapper implementation is categorized as a 
custom interceptor. We could rule out the chain abort now. :)

> By the way, MultivaluedMap has Lists as values, so if you do prefer to
> reuse the code which deals with Lists then you just use
> MultivaluedMap.put(), add() is a utility method which creates a List if
> it's not there...

I didn't notice that. Will adjust my code. :)

Again, my thanks.

Gabo

Sergey Beryozkin wrote:
> Hi Gabo
>
> So it does look like Result prefixes are added by the outbound chain
> somewhere. 
>
> I'm sorry I didn't investigate the issue with custom headers being lost
> when added in a CXF out interceptor - but now that you posted some code
> in the other email I will try to reproduce the problem. 
>
> If you could create a JIRA and attach a sample interceptor and a sample
> service class then it would help a lot and ensure the issue is tracked.
> I'd like to get it fixed as it's important that when JAXWS and JAXRS is
> combined then a single CXF interceptor can be shared to do some custom
> header post-processing.
>
> Another issue was that Result prefixes were added if you used the CXF
> custom interceptor. I'm wondering, was it caused by the fact that the
> chain was aborted (as a workaround around the issue of headers being
> lost)?
>
> By the way, MultivaluedMap has Lists as values, so if you do prefer to
> reuse the code which deals with Lists then you just use
> MultivaluedMap.put(), add() is a utility method which creates a List if
> it's not there...
>
> Thanks, Sergey
>
> -----Original Message-----
> From: Gabo Manuel [mailto:kmanuel@solegysystems.com] 
> Sent: 17 February 2009 10:51
> To: users@cxf.apache.org
> Subject: Re: [JAX-RS] Fault handling
>
> Hi Sergey,
>
> I have replaced the CXFInterceptor with a ResponseHandler 
> implementation. So no chain-abort now. Body of the handleResponse is as 
> follows:
>
>         MultivaluedMap<String, Object> map = response.getMetadata();
>         map.add("Authentication-Info", 
> "nextnonce=\""+RestHandlerUtility.generateNonce(base_path)+"\"");
>         logger.debug("out message headers: " + map);
>         logger.info("response: " + response.getEntity());
>
> As of this point, the entity still does not contain the Result tag
>
> Again, my thanks.
>
> Gabo
>   

RE: [JAX-RS] Fault handling

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabo

So it does look like Result prefixes are added by the outbound chain
somewhere. 

I'm sorry I didn't investigate the issue with custom headers being lost
when added in a CXF out interceptor - but now that you posted some code
in the other email I will try to reproduce the problem. 

If you could create a JIRA and attach a sample interceptor and a sample
service class then it would help a lot and ensure the issue is tracked.
I'd like to get it fixed as it's important that when JAXWS and JAXRS is
combined then a single CXF interceptor can be shared to do some custom
header post-processing.

Another issue was that Result prefixes were added if you used the CXF
custom interceptor. I'm wondering, was it caused by the fact that the
chain was aborted (as a workaround around the issue of headers being
lost)?

By the way, MultivaluedMap has Lists as values, so if you do prefer to
reuse the code which deals with Lists then you just use
MultivaluedMap.put(), add() is a utility method which creates a List if
it's not there...

Thanks, Sergey

-----Original Message-----
From: Gabo Manuel [mailto:kmanuel@solegysystems.com] 
Sent: 17 February 2009 10:51
To: users@cxf.apache.org
Subject: Re: [JAX-RS] Fault handling

Hi Sergey,

I have replaced the CXFInterceptor with a ResponseHandler 
implementation. So no chain-abort now. Body of the handleResponse is as 
follows:

        MultivaluedMap<String, Object> map = response.getMetadata();
        map.add("Authentication-Info", 
"nextnonce=\""+RestHandlerUtility.generateNonce(base_path)+"\"");
        logger.debug("out message headers: " + map);
        logger.info("response: " + response.getEntity());

As of this point, the entity still does not contain the Result tag

Again, my thanks.

Gabo


Gabo Manuel wrote:
> Hi Sergey,
>
> > Can you also do System.out.println(response.getEntity().toString()) 
> in your mapper, before returning ?
>
> 2009-02-17 06:25:53,024 | INFO  [l0-0][             SolegyFaultMapper]

> entity: The server encountered some error. Involved personnel have 
> been notified of this incident. Please contact support for follow-up. 
> Issue #2009480001
>
> TCPMon captured:
> HTTP/1.1 500 Internal Server Error
> Content-Type: text/plain
> Authentication-Info: 
>
nextnonce="MTIzNDg1MTk1MzAzOTphYjk1ZDllOTkzMDEyNWRlZThkY2ExOWExZThjNjYwN
Q==" 
>
> Content-Type: text/plain
> Content-Length: 163
> Server: Jetty(6.1.11)
>
> <Result>The server encountered some error. Involved personnel have 
> been notified of this incident. Please contact support for follow-up. 
> Issue #2009480001</Result>
>
> > I'm bewildered :-) I've no idea where this <Result> is coming 
> from...I've searched the CXF code base for expressions
> > containing 'Result' and found no obvious culprit...
>
> I'm thinking maybe it is translated as a regular bean and that the 
> said class is annotated as such? I tried debugging the         
> OutputStream os = outMessage.getContent(OutputStream.class); step by 
> step to no avail.
>
> Gabo

Re: [JAX-RS] Fault handling

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Sergey,

I have replaced the CXFInterceptor with a ResponseHandler 
implementation. So no chain-abort now. Body of the handleResponse is as 
follows:

        MultivaluedMap<String, Object> map = response.getMetadata();
        map.add("Authentication-Info", 
"nextnonce=\""+RestHandlerUtility.generateNonce(base_path)+"\"");
        logger.debug("out message headers: " + map);
        logger.info("response: " + response.getEntity());

As of this point, the entity still does not contain the Result tag

Again, my thanks.

Gabo


Gabo Manuel wrote:
> Hi Sergey,
>
> > Can you also do System.out.println(response.getEntity().toString()) 
> in your mapper, before returning ?
>
> 2009-02-17 06:25:53,024 | INFO  [l0-0][             SolegyFaultMapper] 
> entity: The server encountered some error. Involved personnel have 
> been notified of this incident. Please contact support for follow-up. 
> Issue #2009480001
>
> TCPMon captured:
> HTTP/1.1 500 Internal Server Error
> Content-Type: text/plain
> Authentication-Info: 
> nextnonce="MTIzNDg1MTk1MzAzOTphYjk1ZDllOTkzMDEyNWRlZThkY2ExOWExZThjNjYwNQ==" 
>
> Content-Type: text/plain
> Content-Length: 163
> Server: Jetty(6.1.11)
>
> <Result>The server encountered some error. Involved personnel have 
> been notified of this incident. Please contact support for follow-up. 
> Issue #2009480001</Result>
>
> > I'm bewildered :-) I've no idea where this <Result> is coming 
> from...I've searched the CXF code base for expressions
> > containing 'Result' and found no obvious culprit...
>
> I'm thinking maybe it is translated as a regular bean and that the 
> said class is annotated as such? I tried debugging the         
> OutputStream os = outMessage.getContent(OutputStream.class); step by 
> step to no avail.
>
> Gabo

Re: [JAX-RS] Fault handling

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Sergey,

 > Can you also do System.out.println(response.getEntity().toString()) 
in your mapper, before returning ?

2009-02-17 06:25:53,024 | INFO  [l0-0][             SolegyFaultMapper] 
entity: The server encountered some error. Involved personnel have been 
notified of this incident. Please contact support for follow-up. Issue 
#2009480001

TCPMon captured:
HTTP/1.1 500 Internal Server Error
Content-Type: text/plain
Authentication-Info: 
nextnonce="MTIzNDg1MTk1MzAzOTphYjk1ZDllOTkzMDEyNWRlZThkY2ExOWExZThjNjYwNQ=="
Content-Type: text/plain
Content-Length: 163
Server: Jetty(6.1.11)

<Result>The server encountered some error. Involved personnel have been 
notified of this incident. Please contact support for follow-up. Issue 
#2009480001</Result>

 > Can you please confirm your own code (interceptors, etc) does not 
wrap the message text ?

There is only one out interceptor, and it only adds the nextnonce as 
seen in the capture above. Code is as follows:

    public void handleMessage(Message message) throws Fault {
        String base_path = (String)message.get(Message.BASE_PATH);
       
        logger.debug("Adding nextnonce...");
        addNextNonce(message, base_path);
       
        /*-
         * The next few steps should not be necessary. However, CXF 
support team
         * is still unable to explain why the added header is 
ignored/overwritten/removed
         *
         * see: 
http://www.nabble.com/-OutInterceptor--HttpHeader--Adding-Authorization-Info-entry-to-http-header-td20375003.html
         */
        message.getInterceptorChain().abort();
        try {
            RestHandlerUtility.getConduit(message).prepare(message);
            RestHandlerUtility.close(message);
        } catch (IOException e) {
            logger.warn(e.getMessage(), e);
        }

    }
   
    /**
     * Note that all values should be quoted as per <a 
HREF="http://www.ietf.org/rfc/rfc2617">RFC</a>.
     *
     * @param message
     * @param base_path
     */
    private void addNextNonce(Message message, String base_path) {
        // Set the response headers
        @SuppressWarnings("unchecked")
        Map<String, List<String>> responseHeaders = (Map<String, 
List<String>>)message.get(Message.PROTOCOL_HEADERS);
       
        if (responseHeaders == null) {
            responseHeaders = new HashMap<String, List<String>>();
            message.put(Message.PROTOCOL_HEADERS, responseHeaders);
        }
       
        responseHeaders.put("Authentication-Info", Arrays.asList(new 
String[]{"nextnonce=\""+RestHandlerUtility.generateNonce(base_path)+"\""}));
        logger.debug("out message headers: " + responseHeaders);
    }

where RestHandlerUtility methods are:

    /**
     * Taken from <a 
HREF="http://chrisdail.com/2008/03/31/apache-cxf-with-http-basic-authentication/">a 
blog of Chris Dail</a>
     */
    static Conduit getConduit(Message inMessage) throws IOException {
        Exchange exchange = inMessage.getExchange();
        EndpointReferenceType target = 
exchange.get(EndpointReferenceType.class);
        Conduit conduit = 
exchange.getDestination().getBackChannel(inMessage, null, target);
        exchange.setConduit(conduit);
        return conduit;
    }

    /**
     * Taken from <a 
HREF="http://chrisdail.com/2008/03/31/apache-cxf-with-http-basic-authentication/">a 
blog of Chris Dail</a>
     */
    static void close(Message outMessage) throws IOException {
        OutputStream os = outMessage.getContent(OutputStream.class);
        try{
            os.flush();
        } catch (Exception e){
            logger.warn("Unable to flush data. " + e.getMessage(), e);
        }
        try{
            os.close();
        } catch (Exception e){
            logger.warn("Unable to close stream. " + e.getMessage(), e);
        }
    }

I had to use this to force the header entry to be included in the 
output. Not aborting the chain results in the header not being included.

 > I'm bewildered :-) I've no idea where this <Result> is coming 
from...I've searched the CXF code base for expressions
 > containing 'Result' and found no obvious culprit...

I'm thinking maybe it is translated as a regular bean and that the said 
class is annotated as such? I tried debugging the         OutputStream 
os = outMessage.getContent(OutputStream.class); step by step to no avail.

Gabo

Re: [JAX-RS] Fault handling

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabo

I'm bewildered :-) I've no idea where this <Result> is coming from...I've searched the CXF code base for expressions containing 
'Result' and found no obvious culprit...
Can you please confirm your own code (interceptors, etc) does not wrap the message text ?
Can you also do System.out.println(response.getEntity().toString()) in your mapper, before returning ?

Thanks, Sergey

> I keep getting this in the tcpmon:
>
> <Result>message</Result>
>

> Hi Sergey,
>
> Thanks for the quick reply. Well, I would be using the same set of providers for what I am working on. But yes, I'll keep that in 
> mind.
>
> > I'm not sure which <Result> tag you're referring to - I couldn't find
> any references on the wiki.
>
> I keep getting this in the tcpmon:
>
> <Result>message</Result>
>
> This is how I defined the toResponse()
>
>        ResponseBuilder rb = Response.status(500);
>        rb.type(MediaType.TEXT_PLAIN);
>        rb.entity("message");
>
> I was wondering if the <Result> could be removed. So it would be just "message".
>
> Again, my thanks.
>
> Gabo
> 


Re: [JAX-RS] Fault handling

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Sergey,

Thanks for the quick reply. Well, I would be using the same set of 
providers for what I am working on. But yes, I'll keep that in mind.

 > I'm not sure which <Result> tag you're referring to - I couldn't find 
any references on the wiki.

I keep getting this in the tcpmon:

<Result>message</Result>

This is how I defined the toResponse()

        ResponseBuilder rb = Response.status(500);
        rb.type(MediaType.TEXT_PLAIN);
        rb.entity("message");

I was wondering if the <Result> could be removed. So it would be just 
"message".

Again, my thanks.

Gabo


Re: [JAX-RS] Fault handling

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabo

> Hi Sergey,
>
> Thanks for pointing me in the right direction. I got most of what I need from this site:
>
> http://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS
>
> One last thing though, is it possible to remove the <Result> tags?

I'm not sure which <Result> tag you're referring to - I couldn't find any references on the wiki.

>
> > Can you explain a bit more what exactly you're trying to do ?
>
> To answer your question, the application is meant to suppress all RuntimeException with a more friendly message and forward that 
> exception and the stacktrace to me. Also, to replace the error message to 400 instead of 500 for the checked exceptions.
>
> Also, I am not sure where in the documentation it could be found, but I wasn't able to find how the mapper would be applied to the 
> endpoint. I tried adding it as a provider and it worked. Not sure if this is the proper way, or I'm just lucky it worked.

Yea, it's just a provider. All the JAXRS providers (body readers/writers, exception mappers, context resolvers) plus CXF extensions 
like  request/response filters and ParameterResolvers can be registered as jaxrs:server/jaxrs:providers/ provider beans... By the 
way one can have unique provider instances (with the unique configuration) per endpoint if needed. For ex, you can control multipart 
thresholds and temp dirs per endpoint by configuring the ActivationProvider accordingly

Cheers, Sergey

>
> Again, my thanks.
>
> Gabo
>
> Sergey Beryozkin wrote:
>> Hi Gabo
>>
>> Can you explain a bit more what exactly you're trying to do ?
>> I think if you have a JAXRS ExceptionMapper for say CustomException which does extend RuntimeException then you'll know in this 
>> mapper's implementation what sort of exception it is...
>>
>> But may be I'm missing something...
>>
>> Cheers, Sergey
>>
>>
>> ----- Original Message ----- From: "Gabo Manuel" <km...@solegysystems.com>
>> To: <us...@cxf.apache.org>
>> Sent: Thursday, February 12, 2009 10:11 AM
>> Subject: [JAX-RS] Fault handling
>>
>>
>>> Hi All,
>>>
>>> I was just wondering if there is a possibility to acquire the actual Exception object, and maybe even replace it with another 
>>> Exception through interceptors.
>>>
>>> I was already able to change the response code (400 or 500) depending on whether the exception was a checked exception or not. I 
>>> would however, prefer to be able to automatically notify some people for the unchecked exceptions. I tried printing all of the 
>>> available content formats (message.getContentFormats()) to no avail.
>>>
>>> Again, thanks in advance.
>>>
>>> Gabo
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com Version: 8.0.234 / Virus Database: 270.10.23/1947 - Release Date: 02/11/09 18:11:00
>>
>> 


Re: [JAX-RS] Fault handling

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Sergey,

Thanks for pointing me in the right direction. I got most of what I need 
from this site:

http://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS

One last thing though, is it possible to remove the <Result> tags?

 > Can you explain a bit more what exactly you're trying to do ?

To answer your question, the application is meant to suppress all 
RuntimeException with a more friendly message and forward that exception 
and the stacktrace to me. Also, to replace the error message to 400 
instead of 500 for the checked exceptions.

Also, I am not sure where in the documentation it could be found, but I 
wasn't able to find how the mapper would be applied to the endpoint. I 
tried adding it as a provider and it worked. Not sure if this is the 
proper way, or I'm just lucky it worked.

Again, my thanks.

Gabo

Sergey Beryozkin wrote:
> Hi Gabo
>
> Can you explain a bit more what exactly you're trying to do ?
> I think if you have a JAXRS ExceptionMapper for say CustomException 
> which does extend RuntimeException then you'll know in this mapper's 
> implementation what sort of exception it is...
>
> But may be I'm missing something...
>
> Cheers, Sergey
>
>
> ----- Original Message ----- From: "Gabo Manuel" 
> <km...@solegysystems.com>
> To: <us...@cxf.apache.org>
> Sent: Thursday, February 12, 2009 10:11 AM
> Subject: [JAX-RS] Fault handling
>
>
>> Hi All,
>>
>> I was just wondering if there is a possibility to acquire the actual 
>> Exception object, and maybe even replace it with another Exception 
>> through interceptors.
>>
>> I was already able to change the response code (400 or 500) depending 
>> on whether the exception was a checked exception or not. I would 
>> however, prefer to be able to automatically notify some people for 
>> the unchecked exceptions. I tried printing all of the available 
>> content formats (message.getContentFormats()) to no avail.
>>
>> Again, thanks in advance.
>>
>> Gabo 
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.0.234 / Virus Database: 270.10.23/1947 - Release Date: 02/11/09 18:11:00
>
>   

Re: [JAX-RS] Fault handling

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabo

Can you explain a bit more what exactly you're trying to do ?
I think if you have a JAXRS ExceptionMapper for say CustomException which does extend RuntimeException then you'll know in this 
mapper's implementation what sort of exception it is...

But may be I'm missing something...

Cheers, Sergey


----- Original Message ----- 
From: "Gabo Manuel" <km...@solegysystems.com>
To: <us...@cxf.apache.org>
Sent: Thursday, February 12, 2009 10:11 AM
Subject: [JAX-RS] Fault handling


> Hi All,
>
> I was just wondering if there is a possibility to acquire the actual Exception object, and maybe even replace it with another 
> Exception through interceptors.
>
> I was already able to change the response code (400 or 500) depending on whether the exception was a checked exception or not. I 
> would however, prefer to be able to automatically notify some people for the unchecked exceptions. I tried printing all of the 
> available content formats (message.getContentFormats()) to no avail.
>
> Again, thanks in advance.
>
> Gabo