2 Replies Latest reply on Mar 11, 2013 4:12 AM by ffang

    Catching org.apache.cxf.interceptor.Fault: Connection refused

    minibiti

      Hi,

       

       

      I am having trouble catching the following exception when calling a web service via CXF:

      org.apache.cxf.interceptor.Fault: Connection refused

       

      Here is what I do:

      I have my route and from there I call a processor which itself does the CXF call.

       

      Here is the route:

      -


      onException(Exception.class).handled(true).process(pollingExceptionsProcessor);

       

      From("quartz://MyTimer/Polling?trigger.repeatInterval=60000&trigger.repeatCount=-1")

          .process(clientProcessor);

      -


       

      And here is my clientProcessor:

      -


      // Creating the JaxWS client dynamically

      JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

      factory.setServiceClass(WSDL.class);

       

      for (BackendService bsi : bsis) {

          wsUrl = bsi.getUrl();

          factory.setAddress(wsUrl);

          WSDL hcWSDL = (WSDL) factory.create();

       

       

          try {

              hcResponse = hcWSDL.healthCheck(hcRequest);

       

              handleHCResponse(hcResponse, bsi.getId());

       

          } catch (WebServiceException wse) {

              log.error(message);

          } catch (Exception ex) {

              log.error(message);

          }

      }

      -


       

      My problem is that when the backend server exposing the web service is down, I get the following exception from the "hcWSDL.healthCheck(hcRequest);" statement:

      org.apache.cxf.interceptor.Fault: Connection refused

      In itself it is not a problem. The problem is that my try/catch does not catch it.

      It gets caught in the pollingExceptionsProcessor in the onException mechanism at the route level!

      And I need to catch it in my try/catch so I can handle it properly and carry on with my loop.

       

      The interesting thing is that if I replace "hcWSDL.healthCheck(hcRequest);" with creating and throwing my own Fault exception then it gets properly caught! Like this:

      Throwable t = new Throwable("I created my own Fault Exception");

      throw new Fault(t);

       

       

      So can someone tell me the following:

      - how can the exception from the WS call  escape the try/catch without being caught?

      - does it have anything to do with some inbuilt CXF interceptors?

      - how can I solve my problem so I can catch the Fault exception in my clientProcessor and prevent it from ending up being caught at the route level?

       

       

      Thanks a lot!

       

       

      JM.