[ 
https://issues.apache.org/jira/browse/CXF-2086?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678786#action_12678786
 ] 

Sergey Beryozkin commented on CXF-2086:
---------------------------------------

Hi,

default WebApplicationExceptionMapper logs at a fine level, as a given 
WebApplicationException might be a part of the application flow :

if (LOG.isLoggable(Level.FINE)) {
            org.apache.cxf.common.i18n.Message errorMsg = 
                new org.apache.cxf.common.i18n.Message("WEB_APP_EXCEPTION", 
                    BUNDLE, ex.getCause() == null ? ex.getMessage() : 
ex.getCause().getMessage());
            LOG.fine(errorMsg.toString());
        }

When JAXBException occurs here's what happens first :

protected static void handleJAXBException(JAXBException e) {
        Throwable t = e.getLinkedException() != null 
            ? e.getLinkedException() : e.getCause() != null ? e.getCause() : e;
        String message = new 
org.apache.cxf.common.i18n.Message("JAXB_EXCEPTION", 
                             BUNDLE, t.getMessage()).toString();
        Response r = Response.status(Response.Status.INTERNAL_SERVER_ERROR)
            .type(MediaType.TEXT_PLAIN).entity(message).build();
        throw new WebApplicationException(t, r);
    }

so this WebApplicationException will be handled by a mapper.

You can add a custom WebApplicationException mapper which would analyze the  
cause and do the right logging.

That said I think I was wrong in enabling the fine-level logging in this case - 
after all WebApplicationException  is a RuntimeException. Will change it to 
'warning'

> I would also request that you review your error handling in general and 
> determine if appropriate logging is in place. 

sure, we'll improve the logging


> CFX does not log caught RuntimeException
> ----------------------------------------
>
>                 Key: CXF-2086
>                 URL: https://issues.apache.org/jira/browse/CXF-2086
>             Project: CXF
>          Issue Type: Improvement
>          Components: REST
>    Affects Versions: 2.1.4
>         Environment: Java 6 and Windows 7
>            Reporter: Matt Helgren
>             Fix For: 2.1.5
>
>
> We are using CXF and the JAXRS component to build our next generation 
> application based on REST services.  Recently we have a very hard time 
> debugging REST requests that fail with a 500 response.  We find that the 
> failures are due to our own issues with JAXB marsharlling but it is very hard 
> to discover because JAXRS and CXF do not report/log the exceptions caught 
> from JAXB.
> JAXB errors seem to be caught by the framework in 
> JAXRSInIntercepter.handleMessage().   Please add some logging to the catch 
> block.  Right now all it does is create a fault response for the client that 
> has very little information about the actual root cause.
> This may seem like a small change but it would help us immensely in our 
> development process with CXF.
> I would also request that you review your error handling in general and 
> determine if appropriate logging is in place. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to