I would like to use the exception mapping feature in a service task, but it does not work for me.
I follow exactly the documentation to declare the mapException (see below), in my Java Delegate, I throw an Exception, I attach an ErrorBoundaryEvent to my service task, but the BpmnError is not propagated to it, just the org.activiti.SomeException is thrown an nothing happens. What am I doing wrong?
In your first example you were using the class attribute of the service task element and in this new example expression. The map exceptions functionality is currently only supported for the class attribute service tasks. An alternative would be to catch the IllegalArgumentException in your expression bean and throw a BpmnError with the correct error code. This would trigger the boundary error event as well.
I understand.
Is there a reason why it’s not supported for expressions?
Most of our service tasks use expressions, so it would be very helpful, if it would be supported (and also support for any Exceptions, not only RuntimeException).
The reason why I would like to attach the exception mapping to the bpmn and not the Java Delegate Bean (by throwing BpmnError) is, that we have different bpmn’s pointing to the same Java Delegate Bean (method), and it should be in the responsibility of the bpmn to decide, if a boundary error event should be triggered or not.
Any chance to add this feature to future flowable releases?
I don’t think there’s a specific reason for it not working with expressions.
So I fully agree it should be added. Will see if I can work on it tomorrow or on Friday so it will be available in the Flowable 6.0.0 release. Are you planning to use Flowable 5? Because then I need to make sure it’s also backported to that version.
Are Exceptions (instead of RuntimeExceptions) supported as well?
Our JavaDelegate Beans inject different kind of (OSGi) Service Beans, which declare checked Exceptions, so, if a service throws a specific exception, I can catch it directly in the BPMN.
In Flowable 5 we have support for checked Exceptions as well. In Flowable 6 we dropped the checked exceptions support and dropped the throws exception in the execute method of the JavaDelegate interface. So in Flowable 6 only RuntimeExceptions are supported.
@tijs sorry for coming back to this issue (we migrated now from 5 to 6), but the missing exception support in expressions (not delegateExpression’s) is some kind of pain of us:
We have many expression like ${myBean.myMethod(..)} , which typically refer to an external Java API, which declares also checked exceptions (which should be catchable in an boundaryerrorevent). If so, I have to rewrite the code to declare everywhere unchecked exceptions or to throw a new BpmnError()
I understand, that you dropped the support for JavaDelegate’s because of removing the exception from the execute method, but for expressions (ServiceTaskExpressionActivityBehavior), it should be fine to support exception !?