Discussion:
[jboss-user] [jBPM] - Exception Handling in jBPM
chian
2012-08-01 07:13:53 UTC
Permalink
chian [https://community.jboss.org/people/chian] created the discussion

"Exception Handling in jBPM"

To view the discussion, visit: https://community.jboss.org/message/751394#751394

--------------------------------------------------------------
Can any one please help me dealing with exception Handling in jBPM.

I'm using a *node* that throws an exception. And I have a class that listens to that particular exception.

But I'm having trouble to make desired transition to another node on getting an exception.

So please HELP...


:) :) :) Thanks in advance... :) :) :)
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/751394#751394]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Maciej Swiderski
2012-08-01 12:47:09 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: Exception Handling in jBPM"

To view the discussion, visit: https://community.jboss.org/message/751443#751443

--------------------------------------------------------------
There are two approaches to this case (and probably even more):
1. model your exception handling in the process, so whenever something wrong happen you will trigger an error event and then model catch error event that will handle exception flow in the process - in my opinion this is recommended so business process covers all scenarios and not only positive flow so to say
2. enhance your work item handlers to deal with exception and signal events that are awaiting error situations

Both most likely will provide you with same result but option 1 in my opinion is clearer as that is visible directly on the process level and not somewhere in the code.

HTH
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/751443#751443]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
chian
2012-08-02 03:40:32 UTC
Permalink
chian [https://community.jboss.org/people/chian] created the discussion

"Re: Exception Handling in jBPM"

To view the discussion, visit: https://community.jboss.org/message/751578#751578

--------------------------------------------------------------
Thank you for the reply.

Actually here is the scenerio..
Loading Image... Loading Image...
Here, when *node1* throws the exception, it should traverse through transition *error*.


*Here is the processdefinition.xml*

<?xml version="1.0" encoding="UTF-8"?>
<process-definition  xmlns="urn:jbpm.org:jpdl-3.2"  name="VitWork">
          <start-state name="Start">
                    <transition to="node1"></transition>
          </start-state>
          <node name="node1" async="true">
                    <event type="node-leave">
                              <action class="com.sample.action.MessageActionHandler1"></action>
                    </event>
                    <transition to="node2" name="ok"></transition>
                    <transition to="Error Handling" name="error"></transition>
          </node>
          <node name="node2" async="true">
                    <event type="node-leave">
                              <action class="com.sample.action.MessageActionHandler2"></action>
                    </event>
                    <transition to="Approve"></transition>
          </node>
          <task-node name="Approve">
                    <task name="Approve"></task>
                    <transition to="end"></transition>
          </task-node>
          <task-node name="Error Handling">
                    <task name="Error Handling"></task>
                    <exception-handler exception-class="java.lang.Exception">
                              <action class="com.sample.exceptionHandler.ExceptionHandler"></action>
                    </exception-handler>
                    <transition to="end-state1"></transition>
          </task-node>
          <end-state name="end"></end-state>
          <end-state name="end-state1"></end-state>
</process-definition>


*Here is the MessageActionHandler1.java*
*
*
package com.sample.action;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

public class MessageActionHandler1 implements ActionHandler {
          private static final long serialVersionUID = 1L;
          public void execute(ExecutionContext context) throws Exception {
                    System.out.println("Thread 1 going to Sleep for 15 seconds...");
                    throw new Exception("Dummy Exception");
          }
}
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/751578#751578]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
chian
2012-08-02 03:42:03 UTC
Permalink
chian [https://community.jboss.org/people/chian] created the discussion

"Re: Exception Handling in jBPM"

To view the discussion, visit: https://community.jboss.org/message/751580#751580

--------------------------------------------------------------
Actually I'm confused with this portion:

<exception-handler exception-class="java.lang.Exception">
                             <action class="com.sample.exceptionHandler.ExceptionHandler"></action>
</exception-handler>

So please help..

I need to go to node "ERROR HANDLING" on throwing an exception by "node1"
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/751580#751580]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
chian
2012-08-03 14:42:43 UTC
Permalink
chian [https://community.jboss.org/people/chian] created the discussion

"Re: Exception Handling in jBPM"

To view the discussion, visit: https://community.jboss.org/message/751912#751912

--------------------------------------------------------------
**:)* *:) * *:) * *:) * *:) * *:) * PROBLEM SOLVED... *:) * *:) * *:) * *:) * *:)**

**Actually Exception Handling is not used to alter the transition...**
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/751912#751912]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Maciej Swiderski
2012-08-04 16:04:21 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: Exception Handling in jBPM"

To view the discussion, visit: https://community.jboss.org/message/752036#752036

--------------------------------------------------------------
Apologies for my comment, just noticed you asked about jbpm v3 and my comment was about jBPM5 :(
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/752036#752036]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Sumeru Saha
2013-08-02 11:21:56 UTC
Permalink
Sumeru Saha [https://community.jboss.org/people/sumerus] created the discussion

"Re: Exception Handling in jBPM"

To view the discussion, visit: https://community.jboss.org/message/831135#831135

--------------------------------------------------------------
Hi Maceij,

We're trying to perform some exception handling in our process. What we have is Script Task 1, Use Task1, ScriptTask2, ScriptTask3 (in order) ... in ScriptTask1 i'm setting a process variable (say, someVar) to some value before landing into the UserTask1. I can see the process variable value refelected in the portal screen. In Script Task2, i'm again setting variable to a different value and finally in ScriptTask3 a java.lang.NPE is thrown. What we observe is that the value of the someVar still has the first value which was set in ScriptTask1 and the value set in ScriptTask2 is rolled back (which is a desired behavior on exception). But the problem is that now the instance is stuck at the ScriptTask3. How do I route this instance into an exception flow or an alternate so that some corrective step can be taken either manually  or systematically and the instance can be salvaged.

Please help with ur valuable suggestion.

Thanks
Sumeru
--- Loading Image... Loading Image...
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/831135#831135]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...