1 Reply Latest reply on Oct 20, 2008 8:47 AM by Rue. SATOH

    CXF UserException not support?

    Ienaga Eiji Newbie

      hi

      I want to throw UserException from server to client
      http://jbossws.jboss.org/mediawiki/index.php?title=User_Guide#Fault_Handling


      but, can't throw UserException

      exclude exception dir
      in jbossws-cxf/tests/resources/test-excludes-jboss423.txt

      Not support UserException?
      If not support, then alternative?

      jbossws-cxf-3.03.G.A

        • 1. Re: CXF UserException not support?
          Rue. SATOH Newbie

          Maybe this is a JBossWS-CXF's bug. JBossWS-CXF wraps all Exception in a RuntimeException and throws it. CXF is catching it, but it can't do nothing.

          I fixed this problem by modified jbossws-cxf-3.0.3.GA/modules/server/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java like that. See below.

          protected void handleException(Exception ex, Exchange exchange, Method m)
           {
           Throwable th = ex;
           if (ex instanceof InvocationTargetException) {
           th = ((InvocationTargetException)ex).getTargetException();
           if (th != null) {
           for (Class<?> cl : m.getExceptionTypes()) {
           if (cl.isInstance(th)) {
           exchange.getInMessage().put(FaultMode.class,
           FaultMode.CHECKED_APPLICATION_FAULT);
           throw new Fault(th);
           }
           }
           if (th instanceof Fault) {
           exchange.getInMessage().put(FaultMode.class,
           FaultMode.CHECKED_APPLICATION_FAULT);
           throw (Fault)th;
           }
           }
           }
          
           exchange.getInMessage().put(FaultMode.class, FaultMode.UNCHECKED_APPLICATION_FAULT);
           if (th instanceof Fault)
           throw (Fault)th;
          
           throw new Fault(th);
           }