cancel
Showing results for 
Search instead for 
Did you mean: 

Process start ExecutionListener and exceptions

lmollea
Champ in-the-making
Champ in-the-making
Hey again,
I have a weird behaviour when in an ExecutionListener I have an exception raised by an Activiti Engine API.
Specifically, at start of a certain process I go looking into the deployment for the starting process if a certain file has been uploaded also, like this:

<blockcode>
RepositoryService repo = execution.getEngineServices().getRepositoryService();
ProcessDefinition pDef = repo.createProcessDefinitionQuery()
    .processDefinitionId(execution.getProcessDefinitionId())
    .singleResult();
InputStream is = repo.getResourceAsStream(pDef.getDeploymentId(), routingName);
// do something with is
</blockcode>

I mis-read the documentation and overlooked the ActivitObjectNotFoundException (I expected a simple null return value as Class.getResorceAsStream() does, no big deal).
Crazy thing is that if I catch and silence the exception, like this:

<blockcode>
try {
   RepositoryService repo = execution.getEngineServices().getRepositoryService();
   InputStream is = repo.getResourceAsStream(pDef.getDeploymentId(), resourceName);
  // do something with is
} catch(ActivitObjectNotFoundException  aonf) {
   log.warn("exta resource not found, skipping")
}
</blockcode>

The task in the process will execute, but then I will have in the log an exception stack trace from the getResourceAsStream and all the transaction will be rolled back.

Why is that?

(Activiti 5.15.1)
1 REPLY 1

trademak
Star Contributor
Star Contributor
Is another Exception being thrown as well?
If you catch the exception then Activiti will not rollback the process instance.

Best regards,