1 Reply Latest reply on Oct 13, 2015 12:09 PM by juan_a_velez

    EAP 6.4.0: WebFault treated as unchecked exception, therefore no detail is being returned

    juan_a_velez

      We are using EAP 6.4.0 (Patch 3) to deploy our Stateless Web Services which include methods that throw Checked Exceptions. These exceptions follow the proposed pattern of including a "fault" bean. When the exceptions are thrown, the returning message includes the exception like any other unchecked exception instead of being treated like a checked exception. We have tracked down the issue to the JBossWSInvoker (actually CXF's AbstractInvoker)'s invoker method (The version of CXF delivered with EAP 6.4.0 Patch 3 is 2.7.16)

       

      It seems since the WebService is a Stateless Session Bean (SLSB), the exception returned is an EJBException which wraps the actual thrown exception and this makes the code to treat it like an unchecked exception. When we deploy the Web Service (sans SLB) in a war the exceptions are caught and the response includes the detail of the exception.

       

      We have searched and we are not the only ones with the issue. Is there a way to solve this while still being able to use SLSB?

       

      catch (InvocationTargetException e) {
      
          Throwable t = e.getCause();
                  
          if (t == null) {
              t = e;
          }
                  
          checkSuspendedInvocation(exchange, serviceObject, m, params, t);
                  
          exchange.getInMessage().put(FaultMode.class, FaultMode.UNCHECKED_APPLICATION_FAULT);
          
          for (Class<?> cl : m.getExceptionTypes()) {
              if (cl.isInstance(t)) {
                  exchange.getInMessage().put(FaultMode.class, 
                                              FaultMode.CHECKED_APPLICATION_FAULT);                    
              }
          }
                  
          if (t instanceof Fault) {
              exchange.getInMessage().put(FaultMode.class, 
                                          FaultMode.CHECKED_APPLICATION_FAULT);                    
              throw (Fault)t;
          }
          throw createFault(t, m, params, true);
      
                  
      

       

         @WebMethod
         public int testMethod() throws MyFault
         {
            throw new MyFault("Hello Juan", new ExceptionFaultBean("Hi Juan", 1000));
         }
      
         @WebFault( name = "OperationError" )
         public static class MyFault extends Exception
         {
            private static final long serialVersionUID = 9053369402082523466L;
      
            private ExceptionFaultBean faultInfo;
      
            public MyFault( String msg , ExceptionFaultBean faultInfo )
            {
               super( msg );
               this.faultInfo = faultInfo;
            }
      
            public MyFault( String msg , ExceptionFaultBean faultInfo , Throwable cause )
            {
               super( msg , cause );
               this.faultInfo = faultInfo;
            }
      
            public ExceptionFaultBean getFaultInfo()
            {
               return faultInfo;
            }
         }
      
         @XmlRootElement( name = "ExceptionFaultBean" )
         public static class ExceptionFaultBean
         {
            private String message;
            private int errorCode;
      
            public ExceptionFaultBean()
            {
            }
      
            public ExceptionFaultBean( String message , int errorCode )
            {
               this.setErrorCode( errorCode );
               this.setMessage( message );
            }
      
            public String getMessage()
            {
               return message;
            }
      
            public void setMessage( String message )
            {
               this.message = message;
            }
      
            public int getErrorCode()
            {
               return errorCode;
            }
      
            public void setErrorCode( int errorCode )
            {
               this.errorCode = errorCode;
            }
         }