I'm trying to add some exception paths into workflows using executionListeners to check conditions during the end event of an activity.
I am passing the execution as a parameter to a bean method on the end event of a service task as follows…
checkForErrorCondition(ActivityExecution execution) {
if(errorCondition()) {
PvmTransition exceptionTransition = execution.getActivity().findOutgoingTransition("exception");
execution.take(exceptionTransition);
}
}
when errorCondition() evaluates to true, and it tries to take the "exception" flow, an exception with the message "already taking a transition" is thrown.
I get the same exception when doing the same on the start event.
I wanted to check if this is the expected behaviour (i.e. there is no way to influence the execution flow from a listener)
As well as the above, I noticed that when calling the checkForErrorCondition method from a serviceTask directly (rather than through a listener) it works fine, but if the service task is part of an embedded subprocess, when transitioning out of the subprocess the same exception ("already taking a transition") is thrown.