Dynamically adding flowNodes to subProcess


i am wondering that i cannot add some simple FlowNodes to an existing subprocess.
I tried to use it like this:


It throws this error msg:

Exception in thread “main” org.camunda.bpm.model.xml.ModelException: New child is not a valid child element type: standardLoopCharacteristics; valid types are: [documentation, extensionElements, auditing, monitoring, categoryValueRef, incoming, outgoing, ioSpecification, property, dataInputAssociation, dataOutputAssociation, resourceRole, loopCharacteristics, laneSet, flowElement, artifact]

Ok so my element type is not the right one.
I know that within subprocess we call the elements flowElements. The error mg says i can add flowElements, but i am not able to achieve this.

So i tried it like this:

FlowElement flowElement = modelInstance.newInstance(FlowElement.class);

But on this i get this error:

Exception in thread “main” org.camunda.bpm.model.xml.impl.util.ModelTypeException: Model element type flowElement is abstract and no instances can be created

So what i am doing wrong and how can i achieve to add some simple flowNodes to this subProcess?
Sry i did not found a possible solution on search engines…

Appreciate your help!
Best Regards Sebastian

The subProcess looks like this and has loop marker attached.
If i remove the loop marker i can add flownodes but with the marker active it is not working.