AnsweredAssumed Answered

Process start ExecutionListener and exceptions

Question asked by lmollea on Jul 16, 2014
Latest reply on Jul 21, 2014 by trademak
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)

Outcomes