cancel
Showing results for 
Search instead for 
Did you mean: 

Execution doesn't stop at User Task, then blows up

mindcrime
Champ in-the-making
Champ in-the-making
Hello all, seeing some weirdness with Activiti 5.10, that I'm hoping someone can help me understand.  I am kinda thinking this may be a bug, but hopefully
it's just something I'm missing about Activiti.

The basic situation is this: I'm working on implementing error handling (technical errors) for service tasks.  I've prototyped a trivial example with one service task.  The goal is to do a sequence flow out to a path that creates a User Task when an exception occurs in the task handler, and a sequence flow out to the happy path otherwise.  I've implemented my handler like this:


public class ThrowsException implements ActivityBehavior, Serializable
{
   @Override
   public void execute( ActivityExecution execution ) throws Exception
   {
      
      System.out.println( "in ThrowsException");
       PvmTransition transition = null;
       try {
          
          if( execution.getVariable("clearException") == null )
          {
             System.out.println( "throwing Exception");
             throw new Exception( "This is fucked!" );
          }
      
          System.out.println( "going no-exception path" );
         transition = execution.getActivity().findOutgoingTransition("no-exception");
        
       }
       catch (Exception e)
       {
          System.out.println( "found Exception, going exception path");
          transition = execution.getActivity().findOutgoingTransition("exception");
       }
      
       execution.take(transition);

   }
   
   
}

The first time through, it won't find a variable called "clearException" so it throws an Exception and takes the "exception" outgoing transition.

The flow then goes to a script task that just does a println so I can see what it's doing, then it goes to a User Task named "Fix Exception".  There's an on completion listener attached to the User Task which injects the "clearException" variable, and then loops back to the beginning.  The second time through the Service Task, it doesn't throw any Exception and proceeds like normal.

So here's the thing… when I setup the Service task as a "class" type and just link in the class, everything works exactly as I just described.   Here's the BPMN for that case:


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20">
  <process id="financialReportWithJavaException2" name="Monthly financial report process">
    <startEvent id="theStart"></startEvent>
    <scriptTask id="scripttask1" name="Script Task" activiti:async="true" activiti:exclusive="false" scriptFormat="groovy">
      <script><![CDATA[System.out.println( "in Script Task" );]]></script>
    </scriptTask>
    <serviceTask id="servicetask1" name="Service Task" activiti:class="org.example.activiti.services.ThrowsException"></serviceTask>
    <scriptTask id="scripttask2" name="Script Task" scriptFormat="groovy">
      <script><![CDATA[println( "after service task successful");]]></script>
    </scriptTask>
    <userTask id="usertask1" name="Fix Exception" activiti:candidateGroups="engineering">
      <extensionElements>
        <activiti:taskListener event="create" class="org.example.activiti.listener.ClearExceptionTaskListener"></activiti:taskListener>
      </extensionElements>
    </userTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <scriptTask id="scripttask3" name="Script Task" scriptFormat="groovy">
      <script><![CDATA[println( "after service task threw Exception");]]></script>
    </scriptTask>
    <sequenceFlow id="flow1" name="" sourceRef="theStart" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="scripttask1" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="no-exception" name="No Exception" sourceRef="servicetask1" targetRef="scripttask2"></sequenceFlow>
    <sequenceFlow id="exception" name="With Exception" sourceRef="servicetask1" targetRef="scripttask3"></sequenceFlow>
    <sequenceFlow id="flow6" name="" sourceRef="scripttask2" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow7" name="" sourceRef="scripttask3" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow8" name="" sourceRef="usertask1" targetRef="scripttask1"></sequenceFlow>
  </process>
</definitions>


However… IF I change the Service Task to an expression style, and put the expression ${handler.execute(execution)}  and inject an instance of ThrowsException under the name "handler" before starting the process, things blow up.  It still enters the service task, throws the Exception, takes the correct out transition… BUT when it gets to the User Task, it doesn't stop.  The completion listener does fire, and then it goes right back into the Service Task, takes the happy path, but when Activiti starts trying to persist things in this scenario, we get a variety of Postgres foreign key violations.  It looks like the User Task is never saved (or is programmatically deleted) in this case.

Here's the BPMN for this case:


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20">
  <process id="financialReportWithJavaException2" name="Monthly financial report process">
    <startEvent id="theStart"></startEvent>
    <scriptTask id="scripttask1" name="Script Task" activiti:async="true" activiti:exclusive="false" scriptFormat="groovy">
      <script><![CDATA[System.out.println( "in Script Task" );]]></script>
    </scriptTask>
    <serviceTask id="servicetask1" name="Service Task" activiti:expression="${handler.execute(execution)}"></serviceTask>
    <scriptTask id="scripttask2" name="Script Task" scriptFormat="groovy">
      <script><![CDATA[println( "after service task successful");]]></script>
    </scriptTask>
    <userTask id="usertask1" name="Fix Exception" activiti:candidateGroups="engineering">
      <extensionElements>
        <activiti:taskListener event="create" class="org.example.activiti.listener.ClearExceptionTaskListener"></activiti:taskListener>
      </extensionElements>
    </userTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <scriptTask id="scripttask3" name="Script Task" scriptFormat="groovy">
      <script><![CDATA[println( "after service task threw Exception");]]></script>
    </scriptTask>
    <sequenceFlow id="flow1" name="" sourceRef="theStart" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="scripttask1" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="no-exception" name="No Exception" sourceRef="servicetask1" targetRef="scripttask2"></sequenceFlow>
    <sequenceFlow id="exception" name="With Exception" sourceRef="servicetask1" targetRef="scripttask3"></sequenceFlow>
    <sequenceFlow id="flow6" name="" sourceRef="scripttask2" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow7" name="" sourceRef="scripttask3" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow8" name="" sourceRef="usertask1" targetRef="scripttask1"></sequenceFlow>
  </process>
</definitions>

The errors we get look like:

Started process with id: 301
done
in Script Task
in ThrowsException
throwing Exception
found Exception, going exception path
after service task threw Exception
Mar 6, 2013 4:04:57 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource FinancialReportProcessWithJavaException2.bpmn
Mar 6, 2013 4:04:58 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XMLSchema currently not supported as typeLanguage
Mar 6, 2013 4:04:58 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XPath currently not supported as expressionLanguage
Mar 6, 2013 4:04:58 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseProcessDefinitions
INFO: Process with id='financialReportWithJavaException2' hasn't the attribute isExecutable set. Please maintain it, so you are compatible to future activiti versions.
Mar 6, 2013 4:04:58 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource FinancialReportProcessWithJavaException2.financialReportWithJavaException2.png
in Script Task
in ThrowsException
going no-exception path
after service task successful
Mar 6, 2013 4:04:58 PM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ?
### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:158)
   at org.activiti.engine.impl.db.DbSqlSession$DeleteById.execute(DbSqlSession.java:146)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:483)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:371)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:157)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:109)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:46)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:679)
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
   at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381)
   at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
   at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
   at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
   at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
   at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
   … 12 more
Exception in thread "pool-1-thread-2" org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ?
### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:158)
   at org.activiti.engine.impl.db.DbSqlSession$DeleteById.execute(DbSqlSession.java:146)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:483)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:371)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:157)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:109)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:46)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:679)
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
   at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381)
   at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
   at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
   at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
   at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
   at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
   … 12 more
in Script Task
in ThrowsException
going no-exception path
after service task successful
Mar 6, 2013 4:09:59 PM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ?
### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:158)
   at org.activiti.engine.impl.db.DbSqlSession$DeleteById.execute(DbSqlSession.java:146)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:483)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:371)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:157)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:109)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:46)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:679)
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
   at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381)
   at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
   at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
   at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
   at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
   at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
   … 12 more
Exception in thread "pool-1-thread-4" org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ?
### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:158)
   at org.activiti.engine.impl.db.DbSqlSession$DeleteById.execute(DbSqlSession.java:146)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:483)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:371)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:157)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:109)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:46)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:679)
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_task_exe" on table "act_ru_task"
  Detail: Key (id_)=(101) is still referenced from table "act_ru_task".
   at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381)
   at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
   at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
   at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
   at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
   at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
   … 12 more

Any thoughts on what might be going on here?  Should this approach work just as well, even when using the Expression based Service Task?  If not, why would these two scenarios behave differently?

Thanks!
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
Expression-bases service-tasks only delegate to the expression, presuming the expression WILL NOT alter execution state (apart form execution variables) and will take the default outgoing flow after the expression has been called. This is a big difference with implementing an ActivityBehaviour, which is in control of the process-flow. An ActivityBehaviour is for advanced use cases, while the regular service-task expression/class mechanism is for incorporating your java-logic in the process.

Why not use a gateway after the service-task, based on an execution-vcariable that is set when the service-task encounters an exception inside it. Even better, you can use throw a BPMNError from the JavaDelegate when your logic threw an exception. This error can be caught by an error-catching event somewhere else and do the "handle exception" logic for you, using pure BPMN.

mindcrime
Champ in-the-making
Champ in-the-making
Expression-bases service-tasks only delegate to the expression, presuming the expression WILL NOT alter execution state (apart form execution variables) and will take the default outgoing flow after the expression has been called. This is a big difference with implementing an ActivityBehaviour, which is in control of the process-flow. An ActivityBehaviour is for advanced use cases, while the regular service-task expression/class mechanism is for incorporating your java-logic in the process.

OK, cool, that more or less explains that then.  Thanks!

Why not use a gateway after the service-task, based on an execution-vcariable that is set when the service-task encounters an exception inside it. Even better, you can use throw a BPMNError from the JavaDelegate when your logic threw an exception. This error can be caught by an error-catching event somewhere else and do the "handle exception" logic for you, using pure BPMN.

Well, the documentation seems to argue against using BPMNError for dealing with "technical" errors, but that certainly is an option.  It probably would have been my first option, except something I read in the docs seemed to be saying "don't do that".  But if you guys think it's OK, I can go back and do it that way.

frederikherema1
Star Contributor
Star Contributor
If it's a logical error that is expected in your process, than you can just model in in with a gateway after the service-task. If it's an error that can occur due to "technical issue" while executing the service-task (not one that is expected regularly, like e.g.. order not found) an error-event is a better choice.

mindcrime
Champ in-the-making
Champ in-the-making
If it's a logical error that is expected in your process, than you can just model in in with a gateway after the service-task. If it's an error that can occur due to "technical issue" while executing the service-task (not one that is expected regularly, like e.g.. order not found) an error-event is a better choice.

Sounds good.  Thanks for the assistance!