Hi All, 

I am facing a similar problem. 

JAXRSValidationInINterceptor is throwing an exception in PRE_INVOKE phase. I
want to catch this exception and return a custom json response to the
client. I have created a custom interceptor which catches the exception ,
takes out the message . I have one exception mapper registered. I am using
that but its not working. No json content is going to the client. Please
help. I want to send JSON response to the client. 

 @Override 
    public void handleMessage(Message aInMessage) throws Fault 
    { 
        Exception e = aInMessage.getContent(Exception.class); 
        Fault f = (Fault)e; 
        if(f.getCause() instanceof ConstraintViolationException){ 
            ConstraintViolationException exception =  
(ConstraintViolationException)f.getCause(); 
            String message =
exception.getConstraintViolations().iterator().next().getMessage(); 
            XRouterError error = new XRouterError("401",message); 
            throw new OperationFailedException(error); 
        } 
    } 



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Handling-fault-in-interceptor-tp4469616p5754766.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to