3 Replies Latest reply on Feb 3, 2015 1:39 AM by Maciej Swiderski

    Error Handling and Exception Handling Not Working as Desired  [JBPM6.1.0.Final]

    SANJAY GAUTAM Expert

      Hi Friends ,

       

      I was trying to make a simple flow where a Activity Like WS-Webservice throw's different errors and testing whether I can catch them by using the "Catching Intermediate Events" "Error" Boundary Event Handler as shown below.

       

      What is the problem ?

      Case 1 : When I am configuring the Error Boundary Event Handler with the Exception "java.lang.IllegalArgumentException"  the exception is working fine and it is able to catch the exception and control goes to the Java Script Task immediately next to it as show in flow.

      How The Exception was Created For Testing ?: Exception was created as I didn't supplied Mode Parameter for the Web Service Task, Web Service Work Item handler  threw the  "java.lang.IllegalArgumentException" which was done intentionally so that error is through.

       

      Case 2 : When I am configuring the Error Boundary Event Handler with the Exception "java.lang.NullPointerException" the exception handler is not working fine and it is not able to catch the exception and control doesn't go to the java script task immediately next to it. as show in flow

      How The Exception was Created For Testing ?: Just Dont configure any thing inside the WS "WebService Task Work Item Handler. Web Service "java.lang.NullPointerException" which was done intentionally so that error is through.

       

      Process Flow Diagram

      ExceptionDetails.png

      What is the Questions ?

      I need a help on right way of using the Error Boundary Event Handler ? Did any one tried catching exception occuring inside the node like above and catching it ? it will be helpful to understand why NullPointerException is not being caught by the Error Handler  , but the same Error handler can catch the IllegalArgumentException Exception what wrong I am doing .?

       

      Thanks

      Sanjay Gautam

        • 1. Re: Error Handling and Exception Handling Not Working as Desired  [JBPM6.1.0.Final]
          Maciej Swiderski Master

          first of all handling technical exceptions within process definition is not really good idea. Better is to always rely on business related exceptions so they can be meaningful to the process itself. Better is to catch technical exception and thrown more business related.

           

          Nevertheless, make sure that the NPE is actually thrown and propagated up to the caller. It will always check the name of the exception (class name) and will search for match in exception handlers - boundary events but not only as event subprocess etc will be taken into consideration as well.

           

          HTH

          • 2. Re: Error Handling and Exception Handling Not Working as Desired  [JBPM6.1.0.Final]
            SANJAY GAUTAM Expert

            Maciej Swiderski wrote:

             

            first of all handling technical exceptions within process definition is not really good idea. Better is to always rely on business related exceptions so they can be meaningful to the process itself. Better is to catch technical exception and thrown more business related.

             

            Nevertheless, make sure that the NPE is actually thrown and propagated up to the caller. It will always check the name of the exception (class name) and will search for match in exception handlers - boundary events but not only as event subprocess etc will be taken into consideration as well.

             

            HTH

            Thanks for the answer Yes Indeed your first point I also agree to it , but as this is just an experimentation to see how things work I was wondering if there is any reason is to why NPE I am not able to catch while I am able to catch IllegalArgumentException.

            I can see that we have handleException in the WebServiceWorkItemHandler parent class/interface I am calling that method , but it is not clear where I have to mention/configure the final handler ?

            • 3. Re: Error Handling and Exception Handling Not Working as Desired  [JBPM6.1.0.Final]
              Maciej Swiderski Master

              when you look at the handler for web service it does not try catch entire execute method but only part of it so it might be the case that NPE is thrown before that try catch block and thus it's not handled as error with boundary event. Make sure that exception is caught in the try catch or wrap that handler with your custom one that will enclose entire execute method with error handling.

               

              HTH

              1 of 1 people found this helpful