How to fail a job on a technical error?

I have a process instance which should fail on a technical error so that I can handle it sometime later using the failed jobs section in the Cockpit.

But how to make a job fail within a ServiceTask (with async before and marked as exclusive)? Is it ok to throw any Java exception except for the class BpmnError?

Furthermore: Is it possible to make a technical error visible to a user task which has been executed one step before the failed service task?

Hi @Mathias_S,

Yes, you can throw any exception. In the Java API, the methods Job#getExceptionMessage and ManagementService#getJobExceptionStacktrace are going to provide you with the exception details afterwards and Cockpit visualizes them as well.

As for your second point, what exactly do you mean? As far as I know, the incident is visualized in Cockpit on that BPMN element that is declared asyncBefore or asyncAfter. If the user task is asyncAfter and the following service task is not asynchronous, the failed job badge should show up on the user task.


Alright, thank you!

You got my second question right and solved my issue. So the way the engine handles technical exceptions is straightforward for Java developers which makes errors fun again :slightly_smiling:

1 Like