I am basically using a modified version of your concurrency example (attached) but I make one of the forks take an ERROR transition and then try to force the process instance to end via :
processEngine.getExecutionService().endProcessInstance(pid,ProcessInstance.STATE_ENDED);
This works fine unless I have an <on event="end"> on the jPDL. In this case an event is fired, after the process ends, to handle the on end event. But this results in a null pointer exception because there are no more activities or transitions at this point. UserCodeReference.getProcessDefinition returns null.
My basic problem is : How do I end a Process Instance if the join is not reached due to an error transition from one of the nodes feeding the join.