jBPM 5 does not allow attaching timer boundary events to WorkItemNode. The following fragment:
<receiveTask completionQuantity="1" id="_2_1_21" implementation="##WebService" instantiate="false"
isForCompensation="false" messageRef="ID_30607364_7317_2206_0052_000400200024"
name="Receive confirmation" startQuantity="1">
<incoming>_2_1_22</incoming>
<outgoing>_2_1_25</outgoing>
</receiveTask>
<boundaryEvent attachedToRef="_2_1_21" id="_2_1_21_1" name="48 Hours">
<outgoing>_2_1_21_2</outgoing>
<timerEventDefinition id="ID_22607364_7317_2206_0052_000400200027">
<timeCycle>P48H</timeCycle>
</timerEventDefinition>
</boundaryEvent>
results in exception:
java.lang.ClassCastException: org.jbpm.workflow.core.node.WorkItemNode cannot be cast to org.jbpm.workflow.core.node.CompositeContextNode
while executing this line (ProcessHandler.java, line #280):
CompositeContextNode compositeNode = (CompositeContextNode) attachedNode;
Both CompositeContextNode and WorkItemNode extend StateBasedNode class, which defines addTimer() - the only method called from ProcessHandler while processing timer boundary event. In other words, changing the offending line to
StateBasedNode compositeNode = (StateBasedNode) attachedNode;
will compile and will not result in run time exception. However, will it run? In other words, would it be sufficient to enable timer boundary events for work item nodes?