You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by gumatias <gu...@matias.com> on 2014/09/25 04:28:06 UTC

Apache CXF ExceptionMapper with request message

I was wondering if something similar to this is possible or if there's a
better way to do it:

public class WebServiceExceptionMapper implements ExceptionMapper<Exception>
{

  private static Logger logger =
LoggerFactory.getLogger(WebServiceExceptionMapper.class);

  @Override
  public Response toResponse(Exception ex, Message requestMessage) {
    logger.error("request=" + httpMessage.etc..etc.., ex);
    return Response.status(Status.INTERNAL_SERVER_ERROR).build();
  }

}

Basically I would like to be able to log not just the exception but the
request message that triggered the error. More specifically if the request
contains a JSON or XML I would like to grab that.



--
View this message in context: http://cxf.547215.n5.nabble.com/Apache-CXF-ExceptionMapper-with-request-message-tp5749201.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Apache CXF ExceptionMapper with request message

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 25/09/14 06:34, gumatias wrote:
> NVM. Figured it out by injecting MessageContext in my ExceptionMapper and
> adding this custom RequestHandler like described here:
> http://cxf.547215.n5.nabble.com/Accessing-JAXRS-JSON-content-directly-td4390185.html
>
You might want consider using JAX-RS 2.0 ContainerRequestFilter, 
supported from CXF 2.7.x, you can access and modify the headers, entity 
stream, etc from the filter

Cheers, Sergey
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Apache-CXF-ExceptionMapper-with-request-message-tp5749201p5749202.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: Apache CXF ExceptionMapper with request message

Posted by gumatias <gu...@matias.com>.
NVM. Figured it out by injecting MessageContext in my ExceptionMapper and
adding this custom RequestHandler like described here:
http://cxf.547215.n5.nabble.com/Accessing-JAXRS-JSON-content-directly-td4390185.html 



--
View this message in context: http://cxf.547215.n5.nabble.com/Apache-CXF-ExceptionMapper-with-request-message-tp5749201p5749202.html
Sent from the cxf-user mailing list archive at Nabble.com.