[JBoss jBPM] - Sub process exception handling, strange behaviour
by norwaytoheaven
Hi,
It seems that exceptions occuring in a subprocess can be handled by a wrong exception handler:
According to the source code (ProcessState.java), if an exception has occured during sub process execution, no exception handler is called at the process state level. If the node before the process state is of type Node, the exception will be catched in the execute method, and then possibly call this node's exception handler.
Here's a unit test to illustrate this:
package test;
|
| import org.jbpm.graph.def.ActionHandler;
| import org.jbpm.graph.def.ProcessDefinition;
| import org.jbpm.graph.exe.ExecutionContext;
| import org.jbpm.graph.exe.ProcessInstance;
|
| import junit.framework.TestCase;
|
| public class Test extends TestCase {
|
| public static String actionHandler = null;
|
| public void test() throws Exception {
| ProcessDefinition def = ProcessDefinition.parseXmlResource("main/processdefinition.xml");
| ProcessInstance p = def.createProcessInstance();
|
| p.signal();
|
| // The exception thrown in the subprocess has been handled by the Node1 exception handler.
| assertEquals("Node1", actionHandler);
|
| }
|
|
| public static class ProcessStateExceptionHandler implements ActionHandler {
|
| public void execute(ExecutionContext executionContext) throws Exception {
| actionHandler = "ProcessState";
| }
| }
|
| public static class Node1ExceptionHandler implements ActionHandler {
|
| public void execute(ExecutionContext executionContext) throws Exception {
| actionHandler = "Node1";
| }
| }
|
| public static class ProcessDefinitionExceptionHandler implements ActionHandler {
|
| public void execute(ExecutionContext executionContext) throws Exception {
| actionHandler = "ProcessDefinition";
| }
| }
|
| public static class Node1ActionHandler implements ActionHandler {
| public void execute(ExecutionContext executionContext) throws Exception {
| executionContext.leaveNode();
| }
| }
|
| public static class Node2ActionHandler implements ActionHandler {
| public void execute(ExecutionContext executionContext) throws Exception {
| throw new Exception();
| }
| }
| }
|
Main process :
<?xml version="1.0" encoding="UTF-8"?>
|
| <process-definition
| xmlns="urn:jbpm.org:jpdl-3.2" name="main">
| <start-state name="start">
| <transition name="" to="node1"></transition>
| </start-state>
| <node name="node1">
| <action class="test.Test$Node1ActionHandler" />
| <transition name="" to="process1"></transition>
| <exception-handler>
| <action class="test.Test$Node1ExceptionHandler" />
| </exception-handler>
| </node>
| <process-state name="process1">
| <sub-process name="sub"/>
| <transition name="" to="end1"></transition>
| <exception-handler>
| <action class="test.Test$ProcessStateExceptionHandler" />
| </exception-handler>
| </process-state>
| <end-state name="end1"></end-state>
| <exception-handler>
| <action class="test.Test$ProcessDefinitionExceptionHandler" />
| </exception-handler>
| </process-definition>
sub process :
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process-definition
| xmlns="urn:jbpm.org:jpdl-3.2" name="sub">
| <start-state name="start">
| <transition name="" to="node2"></transition>
| </start-state>
| <end-state name="end1"></end-state>
| <node name="node2">
| <action class="test.Test$Node2ActionHandler"/>
| <transition name="" to="end1"></transition>
| </node>
| </process-definition>
|
Shouldn't there be a try { } catch (Exception) { raiseException(exception, executionContext);} in the excecute() method of the process state, so that the exception handler mechanism works with that kind of node?
If not, how are we supposed to deal with exceptions occuring in a sub process?
Regards,
Erwan
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4088800#4088800
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4088800
18 years, 7 months
[JBoss Seam] - Seam + stored procs: what's the recommendation?
by asookazian
Just wondering what the official Seam recommendation/stance is regarding using sprocs with Seam web apps?
Other than being tied down to a particular DB vendor due to differences in the SQL syntax, we are aware of this problem.
I've read Gavin King and Martin Fowler stating a good reason to use sprocs is for maximum performance. Assume that this is not an issue for us.
I've done this with a simple use case recently and found resultsets cumbersome to use (dataTables and looping, etc) esp. with dynamic columns. Also, you can't use the Hibernation Validator annotations on the getter methods of the entity bean class (and in JSF using s:validate or s:validateAll tags). Any other Seam/JSF/EJB3 advantages we'd lose out on? Yes, I know about caching and lazy-loading.
The three Seam books I have did not mention sprocs or resultsets at all, as I recall.
So is it basically recommended to convert legacy sprocs to entity beans or POJOs? Not to create new sprocs at all for Seam app use?
And obviously, thanks to a reply on here, we learned it's best to use DataSource (connection-pooled) rather than DriverManager to get DB connections to minimize overhead.
thx.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4088798#4088798
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4088798
18 years, 7 months