I am working on a module, which creates a dynamic workflow and runs it using Activiti Engine. I am using "camunda bpmn2.0 - (7.1.0-Final)" to create the bpmn20.xml file dynamically.
I started my reading from this section, http://docs.camunda.org/latest/guides/user-guide/#bpmn-model-api
And My requirement is something like this
start --> subprocess [ subStart --> servicetask --> subEnd ] --> end
error-boundary-Event
|
|
|--------> errorHandler(serviceTask) --> end2
Here's the code snippet where I am trying to create the boundary event
BoundaryEvent errorBoundaryEvent = createElement(process, "boundary-event", BoundaryEvent.class);
errorBoundaryEvent.setAttachedTo(subProcess);
EventDefinition errorEvent = createElement(process, "error", EventDefinition.class);
errorBoundaryEvent.getEventDefinitions().add(errorEvent);
here,
process, is the Main process
subProcess, is the sub process
This is giving me the following error,
org.camunda.bpm.model.xml.impl.util.ModelTypeException: Model element type eventDefinition is abstract and no instances can be created.
at org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl.createModelElementInstance(ModelElementTypeImpl.java:98)
at org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl.newInstance(ModelElementTypeImpl.java:77)
at org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl.newInstance(ModelElementTypeImpl.java:72)
at org.camunda.bpm.model.xml.impl.ModelInstanceImpl.newInstance(ModelInstanceImpl.java:79)
at org.camunda.bpm.model.xml.impl.ModelInstanceImpl.newInstance(ModelInstanceImpl.java:71)
Can anyone please guide me to any example code, having such error handling boundary event?
SubProcess subprocess = modelInstance.getModelElementById("subprocess");
BoundaryEvent boundaryEvent = modelInstance.newInstance(BoundaryEvent.class);
boundaryEvent.setAttachedTo(subprocess); process.addChildElement(boundaryEvent);
ErrorEventDefinition errorEventDefinition = modelInstance.newInstance(ErrorEventDefinition.class);
boundaryEvent.getEventDefinitions().add(errorEventDefinition);
Cheers,
Sebastian
Also, I really like using Camunda BPMN2.0 model API, as compared to API's provided by other engine providers.