5 Replies Latest reply on Jun 13, 2014 1:39 AM by swiderski.maciej

    Catch org.jbpm.workflow.instance.WorkflowRuntimeException with Error Boundary Event

    marcj

      HI guys,

      I'm recently working with error boundary events and already posted several questions regarding that topic. At the moment, I want to catch a org.jbpm.workflow.instance.WorkflowRuntimeException via a error boundary event. My setup is as follows:

       

      - Sample process incorporates a custom web service task retrieving the current conversion rate between two currencies. Works fine.

      - I now have attached an error boundary event to this service task.

      - When throwing a java.lang.RuntimeException as OnEntry or OnExit operation, the approprate configured error boundary event gets triggered as expected.

      - I now provoke a org.jbpm.workflow.instance.WorkflowRuntimeException by submitting an incorrect payload to the web service (currency code ABC, which does not exist)

      - The updated error boundary event (catching exactly this error type) does not get triggered.

      - Instead of that, I receive the following error message when initiating the process via the REST interface:

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

      <response>

          <status>FAILURE</status>

          <error>[payments_PT_IRL.payments_PT_IRL:7.253 - Validate Payee IBAN:7] -- [payments_PT_IRL.payments_PT_IRL:7.253 - Get Exchange Rate:14] -- No enum constant net.webservicex.Currency.ABC</error>

          <stackTrace>org.jbpm.workflow.instance.WorkflowRuntimeException: [payments_PT_IRL.payments_PT_IRL:7.253 - Validate Payee IBAN:7] -- [payments_PT_IRL.payments_PT_IRL:7.253 - Get Exchange Rate:14] -- No enum constant net.webservicex.Currency.ABC

        at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:135)

      [...]

        at java.lang.Thread.run(Thread.java:744)

      Caused by: org.jbpm.workflow.instance.WorkflowRuntimeException: [payments_PT_IRL.payments_PT_IRL:7.253 - Get Exchange Rate:14] -- No enum constant net.webservicex.Currency.ABC

        at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:135)

      [...]

        ... 89 more

      Caused by: java.lang.IllegalArgumentException: No enum constant net.webservicex.Currency.ABC

        at java.lang.Enum.valueOf(Enum.java:236)

        at net.webservicex.Currency.valueOf(Currency.java:172)

        at net.webservicex.Currency.fromValue(Currency.java:333)

        at org.jbpm.payments.services.ExchangeRateWorkItemHandler.executeWorkItem(ExchangeRateWorkItemHandler.java:33)

        at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalExecuteWorkItem(JPAWorkItemManager.java:56)

        at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:124)

        ... 131 more

      </stackTrace>

      </response>

       

       

      - When changing the error boundary event to be triggered by a java.lang.IllegalArgumentException, I receive the following stack trace:

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

      <response>

          <status>FAILURE</status>

          <error>[payments_PT_IRL.payments_PT_IRL:7.254 - Validate Payer IBAN:6] -- [payments_PT_IRL.payments_PT_IRL:7.254 - Get Exchange Rate:14] -- unable to execute Action</error>

          <stackTrace>org.jbpm.workflow.instance.WorkflowRuntimeException: [payments_PT_IRL.payments_PT_IRL:7.254 - Validate Payer IBAN:6] -- [payments_PT_IRL.payments_PT_IRL:7.254 - Get Exchange Rate:14] -- unable to execute Action

        at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:135)

        at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:155)

      [...]

        ... 133 more

      Caused by: java.lang.UnsupportedOperationException: Not supported yet.

        at org.jbpm.payments.services.ExchangeRateWorkItemHandler.abortWorkItem(ExchangeRateWorkItemHandler.java:45)

        at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalAbortWorkItem(JPAWorkItemManager.java:93)

        at org.jbpm.workflow.instance.node.WorkItemNodeInstance.cancel(WorkItemNodeInstance.java:285)

        at org.jbpm.process.instance.impl.CancelNodeInstanceAction.execute(CancelNodeInstanceAction.java:41)

        at org.jbpm.workflow.instance.impl.NodeInstanceImpl.executeAction(NodeInstanceImpl.java:182)

        ... 142 more

      </stackTrace>

      </response>

       

      I'm confuesed - can someone clarify that for me?

      Thanks in advance!

      Cheers,

      MarcJ

        • 1. Re: Catch org.jbpm.workflow.instance.WorkflowRuntimeException with Error Boundary Event
          swiderski.maciej

          if this is your custom handler, then it must extend AbstractLogOrThrowWorkItemHandler and in case of error invoke handleException method of that handler. That would make sure that proper wrapping take place and attempt to locate any error catch events.

           

          HTH

          1 of 1 people found this helpful
          • 2. Re: Catch org.jbpm.workflow.instance.WorkflowRuntimeException with Error Boundary Event
            marcj

            Hi Maciej,

            thx for your reply. I've updated my custom work item handler to extend the AbstractLogOrThrowWorkItemHandler and included the necessary try/catch operations. I added this to the import section of the WIH:

             

            import org.jbpm.process.workitem.AbstractLogOrThrowWorkItemHandler;

             

            When trying to compile the project, I get the following error:

             

            [ERROR] \Users\marcj_000\git\crm2\payments_workitems\src\main\java\org\jbpm\payments\services\ExchangeRateWorkItemHandler.java:[9,32] error: package org.jbpm.process.workitem does not exist

             

            I suppose this is caused by a missing dependency in the pom.xml, right? Can you give me a hint which one is required?

            • 3. Re: Catch org.jbpm.workflow.instance.WorkflowRuntimeException with Error Boundary Event
              swiderski.maciej

              jbpm-workitems is the module you're missing.

              • 4. Re: Catch org.jbpm.workflow.instance.WorkflowRuntimeException with Error Boundary Event
                marcj

                Hey Maciej,

                have to come back to you again. I have been able to run a maven build and integrate the handleException(ex); method provided by the AbstractLogOrThrowWorkItemHandler. However, the error boundary event still does not catch the expected error:

                 

                <response>

                <status>FAILURE</status>

                <url>/jbpm-console/rest/runtime/com.XXX:payments_PT_IRL:1.0/process/payments_PT_IRL.payments_PT_IRL/start?XXX</url>

                <error>[payments_PT_IRL.payments_PT_IRL:7.297 - Validate Payer IBAN:6] -- [payments_PT_IRL.payments_PT_IRL:7.297 - Get Exchange Rate:14] -- java.lang.IllegalArgumentException: No enum constant net.webservicex.Currency.ABC</error>

                <stackTrace>...

                 

                Error has been defined on the process level:

                <bpmn2:error id="java.lang.IllegalArgumentException" errorCode="java.lang.IllegalArgumentException"/>

                 

                Boundary event definition looks fine to me:

                <bpmn2:boundaryEvent id="_2B00A285-6082-4E3A-BD48-7DCE16FE4B1E" drools:bgcolor="#f5deb3" drools:selectable="true" drools:bordercolor="#a0522d" drools:boundaryca="true" name="Error Boundary Event" attachedToRef="_EACC3F59-598B-4F80-81DC-15E35D14D17C">

                      <bpmn2:outgoing>_AB140AB0-629F-436B-90AE-32C5BFAD388E</bpmn2:outgoing>

                      <bpmn2:errorEventDefinition id="_vn8nX_FiEeOHoMB4uAfxTA" drools:erefname="java.lang.IllegalArgumentException" errorRef="java.lang.IllegalArgumentException"/>

                    </bpmn2:boundaryEvent>

                 

                Any clues why the process instance behaves like that?

                • 5. Re: Catch org.jbpm.workflow.instance.WorkflowRuntimeException with Error Boundary Event
                  swiderski.maciej

                  Marc, could you provide simple project with your process and test case so I can take a look and try to help out? It looks ok when looking at these separate bits so canät do much without seeing the bigger picture so to say

                   

                  HTH