How to create Edges between two tasks in different lanes


Hello everyone,

I’m trying to programmatically create edges between two tasks in two lanes. I already managed to get two lanes with the tasks in them, but I can’t create the edge between them.

I have a method called createEdge which is responsible for drawing the edge between to shapes. This works great if I try to create an edge between a Task and a Document (in the same lane), but it doesn’t work if I try to create an Edge between two tasks in different lanes.

private BpmnEdge createEdge(BaseElement sequenceFlow, String id, Shape source, Shape target) {

    // create edge for sequence flow
    BpmnEdge flowEdge = modelInstance.newInstance(BpmnEdge.class);
    // create waypoints for sequence flow edge
    Waypoint startWaypoint = modelInstance.newInstance(Waypoint.class);
    startWaypoint.setX(source.getBounds().getX() + source.getBounds().getWidth() / 2);
    startWaypoint.setY(source.getBounds().getY() + source.getBounds().getHeight() / 2);

    Waypoint endWaypoint = modelInstance.newInstance(Waypoint.class);
    endWaypoint.setY(target.getBounds().getY() + source.getBounds().getHeight() / 2);

    return flowEdge;

The error I’m getting is:
org.camunda.bpm.model.xml.ModelValidationException: DOM document is not valid, so it has something to do with this method.

If I don’t create the Edge between the tasks, I get this XML Structure, which I think is correct:

  <process id="process_main" name="process">

    <laneSet id="laneset_main" name="">
      <lane id="lane9" name="Rolle 1">
      <lane id="lane10" name="Rolle 2">

    <task id="act23" name="AKT 1">
    <task id="act22" name="AKT 2">

    <sequenceFlow id="act23-act22" name="" sourceRef="act23" targetRef="act22"/>


Can someone help me with this?