1

I need to catch exception of business logic and cut down its message (stack trace of exception, I don't want to log a bunch of stack trace, just exception type and its message). According to the examples in internet, I have to override or implement handleFault(Message message) method. I have web method for which I attached Interceptor class implements org.apache.cxf.interceptor.Interceptor. But It doesn't work. There is no sign of its call. I can't find any solution surfing through internet.

My web service :

@Stateless
@WebService(name = "LocationServicesWS", targetNamespace = "http://com.example.apps.sc.ws", serviceName = "locationServices")
@WebContext(contextRoot = "/bb/sc", urlPattern = "/lb", transportGuarantee = "NONE", secureWSDLAccess = false)
@Pool("sl-strict-pool")
public class LbServices implements IServicesLocal, IServicesRemote {

@WebMethod
@Override
@Interceptors(TestFaultInterceptor.class)
public LbLocation getLbsLocationService(@WebParam(name="ms")String ms, @WebParam(name="serID")Long ser) throws ScAccViolation, LbsException {
    return serviceProcesses.getLbsLocationForService(ms, ser);
}
}

My custom interceptor:

@Interceptor
@Priority(Interceptor.Priority.APPLICATION)
public class TestFaultInterceptor implements org.apache.cxf.interceptor.Interceptor {
    private static Logger logger = Logger.getLogger(String.valueOf(TestFaultInterceptor.class));

    @Override
    public void handleMessage(Message message) throws Fault {
     //this method is not invoked
      logger.info("handleMessage");
    }

    @Override
    public void handleFault(Message message) {
      //this method is also not invoked
      logger.info("handleFault");
    }

    /*
        @AroundInvoke
        public Object intercept(InvocationContext invocationContext) throws Exception {
            // This method works fine. 
            return invocationContext.proceed();
        }
    */

But in my Interceptor class when I don't implement Interceptor and put annotation @AroundInvoke it works. So what's the problem ? Is there any solution without creating additional *.xml files ?

I have even put annotation

@Priority(Interceptor.Priority.APPLICATION)

But it's to no avail. Here are links I stumbled in the internet (especially how to not log whole stack trace).

Apache CXF JAX-WS return fault without logging exception

How to get incoming & outgoing soap xml in a simple way using Apache CXF?

Community
  • 1
  • 1

0 Answers0