Skip to content
Advertisement

Java – Camunda BPMN model API: how to save valid xml?

I’m building some test BPMN 2.0 models and saving them to xml files, in a Java project, by following the examples provided by the official doc, in this case the example 2.

I imported the lib in my pom like below:

JavaScript

and this is my test class, following the example 2:

JavaScript

Here the generated BPMN 2.0 xml

JavaScript

Altough the validation method, the generated xml appears to be invalid when trying to display the BPMN using both the Camunda Modeler app and bpmn.io.

What is wrong with this example, hence with my code? How can I make the generated xml to be valid? Since bpmn 2.0 is a standard, I’m also a bit surprised of this problem.

Advertisement

Answer

I finally got it working by switching to the fluent model builder API, following this https://blog.camunda.com/post/2014/02/the-new-camunda-bpmn-model-api/

This is my updated test calss:

JavaScript

and this is the generated xml:

JavaScript

By comparing it to the above xml, I notice a few new <bpmndi ...> elements not present before.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement