Bpmn.createEmptyModel() xml error on CamundaModeller.exe

Hello,
I want to create a bpmn userTask xml.

using this code:

BpmnModelInstance modelInstance = Bpmn.createEmptyModel();
Definitions definitions = modelInstance.newInstance(Definitions.class);
definitions.setTargetNamespace(“The Universal Process Orchestrator | Camunda”);
modelInstance.setDefinitions(definitions);

Process process = createElement(modelInstance, definitions,“process-with-one-task”, Process.class);

UserTask task = createElement(modelInstance, process, “task”, UserTask.class);
task.setName(“User Task”);

Bpmn.validateModel(modelInstance);
return Bpmn.convertToString(modelInstance);

and getting this xml:

when copy this xml and paste on CamundaModeller.exe it says me;

image

I am using this version;
implementation(‘org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter:3.3.1’)
implementation(‘org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-webapp:3.3.1’)
implementation(‘org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-rest:3.3.1’)

What’s wrong on my code?
Thank you!

It looks like you’re not using the builder correctly,
Take a look at these docs, that might help

2 Likes

Thank you so much @Niall ,
I need to ask one more question. :frowning:

If I want to add a few formFields with types for userTask what should I do?

final BpmnModelInstance modelInstance = Bpmn.createProcess("process-example")
			      .startEvent()
			      .userTask().name("Name")
			      	.camundaFormKey("Key")
			      	.camundaFormField()
			      	//.camundaId("amount")
			      	//.camundaType("double")
			      	//.camundaLabel("Amount")
			      	.camundaFormFieldDone()
			      .endEvent()
			      .done();

thank you!