Axis2
  1. Axis2
  2. AXIS2-4280

Handle error handling of AxisFault better

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4.1
    • Fix Version/s: 1.5.3, 1.6.0
    • Component/s: kernel
    • Labels:
      None
    • Environment:
      NA

      Description

      Every time I throw an application fault the error gets displayed in server side as an error.

      To reproduce: run the faulthandling example from the distribution (xis2-1.4.1/samples/faulthandling)

      In the server side you get:

      ERROR] Account does not exist!
      org.apache.axis2.AxisFault: Account does not exist!
      at example.BankServiceMessageReceiverInOut.createAxisFault(BankServiceMessageReceiverInOut.java:237)
      at example.BankServiceMessageReceiverInOut.invokeBusinessLogic(BankServiceMessageReceiverInOut.java:75)
      at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
      at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
      at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
      at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
      at org.apache.axis2.transport.http.HTTPWorker.service(HTTPWorker.java:278)
      at org.apache.axis2.transport.http.server.AxisHttpService.doService(AxisHttpService.java:281)
      at org.apache.axis2.transport.http.server.AxisHttpService.handleRequest(AxisHttpService.java:187)
      at org.apache.axis2.transport.http.server.HttpServiceProcessor.run(HttpServiceProcessor.java:82)
      at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
      at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
      at java.lang.Thread.run(Thread.java:613)

      I tracked the source of the error and it is in class AxisEngine line 212 where it blindly logs all faults as errors:

      catch (AxisFault e)

      { log.error(e.getMessage(), e); // <<<<< msgContext.setFailureReason(e); flowComplete(msgContext); throw e; }

      Now, the only way to deal with it now is to switch off logging which is never a good idea. This is a serious bad issue if you want to use faults.

        Issue Links

          Activity

          Hide
          Deepal Jayasinghe added a comment -

          how about submitting a patch ?

          Show
          Deepal Jayasinghe added a comment - how about submitting a patch ?
          Hide
          Dino added a comment -

          I would just remove the log.error(e.getMessage()). I don't think you need a real patch for that.

          It is not good coding practice to log an error and propagate the exception since it can be treated by the client code in a specific manner.

          This is especially true of faults since it is part of the contract of the web service call.

          Show
          Dino added a comment - I would just remove the log.error(e.getMessage()). I don't think you need a real patch for that. It is not good coding practice to log an error and propagate the exception since it can be treated by the client code in a specific manner. This is especially true of faults since it is part of the contract of the web service call.
          Hide
          Amila Chinthaka Suriarachchi added a comment -

          fixed with revision 817965.

          now axis2 only logs non Application level issues

          eg.
          if (e.getFaultType() != Constants.APPLICATION_FAULT)

          { log.error(e.getMessage(), e); }
          Show
          Amila Chinthaka Suriarachchi added a comment - fixed with revision 817965. now axis2 only logs non Application level issues eg. if (e.getFaultType() != Constants.APPLICATION_FAULT) { log.error(e.getMessage(), e); }
          Hide
          Kim Damevin added a comment - - edited

          I have the same problem on Axis-2 version 1.5.1 (seems to be also present on v 1.5.2).
          Can you apply this change on this branch ?

          Show
          Kim Damevin added a comment - - edited I have the same problem on Axis-2 version 1.5.1 (seems to be also present on v 1.5.2). Can you apply this change on this branch ?
          Hide
          Andreas Veithen added a comment -

          Merged to the 1.5 branch. Will be available in 1.5.3.

          Show
          Andreas Veithen added a comment - Merged to the 1.5 branch. Will be available in 1.5.3.

            People

            • Assignee:
              Unassigned
              Reporter:
              Dino
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development