Error handling in service task implementation


#1

Hello,

in a service task implementation, an SSB is called. On exception, I want to throw a BpmnError:

@Named("ServiceTaskFoo")
public class ServiceTaskFoo implements JavaDelegate 
{
     @Inject
     private FooApi fooApi;
 
     @Override
     public void execute(DelegateExecution delegateExecution)
     {
         try
         {
             fooApi.execute();
         }
         catch(Exception e)
         {
             throw new BpmnError("FOO_NOT_POSSIBLE", "Could not complete Foo.");
         }
     }
 }

The exception caught is of type EJBTransactionRolledbackException. Thus, I get

 [...]
 Caused by: org.apache.ibatis.exceptions.PersistenceException: 
 ### Error querying database.  Cause: java.sql.SQLException: IJ031070: Transaction cannot proceed: TATUS_MARKED_ROLLBACK
 ### The error may exist in org/camunda/bpm/engine/impl/mapping/entity/Execution.xml
 ### The error may involve org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.selectExecutionsByProcessInstanceId
 ### The error occurred while executing a query
 ### SQL: select * from ACT_RU_EXECUTION     where PROC_INST_ID_ = ?
 ### Cause: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_MARKED_ROLLBACK
 	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
[...]

I am a bit stuck here. But maybe this error is an indication, that what I am trying to do is not the way, it should be done?

Greetings
Clemens


#2

Hi Clemens,

Maybe this post provides the solution: https://groups.google.com/forum/#!topic/camunda-bpm-users/IOCeVEiwOAE

Cheers,
Thorben