Deployment: addClasspathResource works, addString/addInputStream etc, not

I am using Java 21 and Flowable 7.1.0. I created a small BPMN with bpmn-io and tried to add the flowable extensions for execution with a code-generator.
Then I tried to deploy the resulting String in a flowable process engine (addString).
There is no error, when calling “deploy()” but

        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
                .deploymentId(deployment.getId())
                .singleResult();
        log.info("Found process definition : {}", processDefinition.getName());

fails with a Null Pointer Exception.

When I copy the string to an XML File, place it in src/main/resource everything works fine.
I tried to:

  • Convert String to byte with Charset-UTF8 and use addBytes() → Same null pointer
  • Convert String to a File, instantiating an inputStream on it and use addInputStream() → Same null pointer

I extracted the problem to a minimal working example:

flowable-getting-started.zip

Here is the XML Content of the file
<?xml version="1.0" encoding="UTF-8" standalone="no"?><definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:flowable="http://flowable.org/bpmn" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="18.6.1" id="sid-38422fae-e03e-43a3-bef4-bd33b32041b2" targetNamespace="http://bpmn.io/bpmn"><process id="Process_1" isExecutable="true" name="Hello World Process"><startEvent id="StartEvent_1y45yut" name="hunger noticed"><outgoing>SequenceFlow_0h21x7r</outgoing></startEvent><sequenceFlow id="SequenceFlow_0h21x7r" sourceRef="StartEvent_1y45yut" targetRef="Task_1hcentk"/><serviceTask flowable:class="org.flowable.examples.task.HelloWorldDelegate" id="Task_1hcentk" name="choose recipe"><incoming>SequenceFlow_0h21x7r</incoming><outgoing>Flow_1kfubm7</outgoing></serviceTask><endEvent id="Event_1sfoqr3"><incoming>Flow_1kfubm7</incoming></endEvent><sequenceFlow id="Flow_1kfubm7" sourceRef="Task_1hcentk" targetRef="Event_1sfoqr3"/></process><bpmndi:BPMNDiagram id="BpmnDiagram_1"><bpmndi:BPMNPlane bpmnElement="Process_1" id="BpmnPlane_1"><bpmndi:BPMNShape bpmnElement="StartEvent_1y45yut" id="StartEvent_1y45yut_di"><omgdc:Bounds height="36" width="36" x="152" y="102"/><bpmndi:BPMNLabel><omgdc:Bounds height="14" width="73" x="134" y="145"/></bpmndi:BPMNLabel></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="Task_1hcentk" id="Activity_18hidv9_di"><omgdc:Bounds height="80" width="100" x="240" y="80"/></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="Event_1sfoqr3" id="Event_1sfoqr3_di"><omgdc:Bounds height="36" width="36" x="392" y="102"/></bpmndi:BPMNShape><bpmndi:BPMNEdge bpmnElement="SequenceFlow_0h21x7r" id="SequenceFlow_0h21x7r_di"><omgdi:waypoint x="188" y="120"/><omgdi:waypoint x="240" y="120"/></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="Flow_1kfubm7" id="Flow_1kfubm7_di"><omgdi:waypoint x="340" y="120"/><omgdi:waypoint x="392" y="120"/></bpmndi:BPMNEdge></bpmndi:BPMNPlane></bpmndi:BPMNDiagram></definitions>

Can you see, what I am doing wrong? And why does the deploy() and validation behind it not result in any errors?
Thanks in advance and kind regards,
Michael

Hey @michael.burger,

Can you please create a GitHub repo instead of a zip file like this?

Cheers,
Filip

I did it here:

Also I think its much more complicated for everyone compared to downloading a 10kb zip and extracting it…
Regards,
Michael

Thanks @michael.burger,

However, it is less secure.

Anyways, I had a look at it. You are doing

.addString("user.xml", text)

The problem is that we do not know what this xml extension is. So what you need to do is to either make sure that it ends with .bpmn20.xml or .bpmn. When I change it to some of that then it works properly. i.e. the ProcessDefinition is there, it fails on something else down the line.

The addClasspathResource works because your resource name ends with .bpmn.

Cheers,
Filip

Thanks. This works. The process is deployed and I can query it.