Deploying process as InputStream doesnt deploy correctly as bpmn resource file

I’m writing a groovy builder to generate simple bpmn processes. My builder class provides a method ‘exportAsInputStream’, which takes the formatted process and generates an InputStream from the toString() internally. the generated xml from builder looks like this

<?xml version="1.0" encoding="UTF-8"?> 
<definitions name="hardcodedname" id="def_1" 
	targetNamespace="com.softwood"
	xmlns="http://www.omg.org.spec/BPMN/20100524/MODEL"
	xmlns:flowable="http://flowable.org/bpmn"
	xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
	xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
	xmlns:di="http://www.omg.org/spec/20100524/DI"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	typeLanguage="http://www.w3.org/2001/XMLSchema">

	
	<!--    Structures and Messages -->
	<import importType="http://www.w3.org/2001/XMLSchema" 	location="DataDefinitions.xsd" 	namespace="http://www.example.org/Messages"/>
	<import importType="http://schemas.xmlsoap.org/wsdl/" 	location="Interfaces.wsdl" 	namespace="http://www.example.org/Messages"/>
	
	<!-- process definition -->
	<process id="p_1" name="builderScriptProcess">
		<startEvent id="e_1" name="startProc" />
		<sequenceFlow id="f_2" name="transition" sourceRef="e_1" targetRef="e-2" />
		<endEvent id="e_2" name="endproc" />
	</process>
</definitions>

i then created a test to try and deploy the content

    @Test
    void GroovyBPMBuilderSimpleTest() {
        BpmnProcessBuilder bpmn = new BpmnProcessBuilder()
        bpmn.process("builderScriptProcess", id:"p_1") {
            start("startProc", id:"e_1")
            flow ('transition', source:"e_1", target:"e-2")
            end ("endproc", id: "e_2")
        }

        DeploymentBuilder depBldr = repositoryService.createDeployment()
        depBldr.name"named deployment"
        //resourcename is  name of process, stream is actual defn
        InputStream ins = bpmn.exportAsInputStream()
        depBldr.addInputStream("builderScriptProcess", ins)
        //depBldr.addClasspathResource("com/softwood/spring/junit4/BpmnBuilderSimpleTest.bpmn20.xml")
        Deployment myDeployment = depBldr.deploy()
        assert myDeployment.id == "1"

as you can see ive got the ‘addInputStream’ method in this and the ‘addClasspathResource’ commented out

when i look at these in the debugger they are very different. I get a deployment (id=1), but the deployment.deployedArtifacts field is null, and i cant query for a process

If i re run the test and comment out loading from stream, and load a file classPathResource, I do get deployedArtifacts and i can query the process.

All the examples i can find all seem to use the addClasspathResource method and not an input stream.

i had a peek at the master source tree for v6.2 which has following. where addClasspathResource reflects for file and then passes to addInputStream. The only difference is that my resourceName attribute parameter is a ‘made-up name’ as i have no real file - just a string exposed as an InputStream as the second parameter.

   @Override
    public DeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {
        if (inputStream == null) {
            throw new ActivitiIllegalArgumentException("inputStream for resource '" + resourceName + "' is null");
        }
        byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);
        ResourceEntity resource = new ResourceEntity();
        resource.setName(resourceName);
        resource.setBytes(bytes);
        deployment.addResource(resource);
        return this;
    }

    @Override
    public DeploymentBuilder addClasspathResource(String resource) {
        InputStream inputStream = ReflectUtil.getResourceAsStream(resource);
        if (inputStream == null) {
            throw new ActivitiIllegalArgumentException("resource '" + resource + "' not found");
        }
        return addInputStream(resource, inputStream);
    }

so why does a real file work - where my generated xml string exposed as InputStream does not.

Perplexed and stuck at the moment. Appreciate if anyone can get me over my hurdle

my project in dev on github is here https://github.com/woodmawa/flowable

think i spotted it eventually, though i saw no errors it wasnt correctly naming the namespace refs - so looked at manual file off web, and my generated file and i hadnt quite typed the names correct for default namepsave and the DI didnt resolve, after some digging i corrected and i now generate this - which appears to parse and reslove names. now when i send the inputStream to the method and a name string the artifacts appear to deploy.

so i think i have the boilerplating right - now go finish rounding out the groovy builder

<?xml version="1.0" encoding="UTF-8"?> 
<definitions name="myProcessDefinition" id="def_1" 
	targetNamespace="com.softwood"
	xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
	xmlns:flowable="http://flowable.org/bpmn"
	xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
	xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
	xmlns:di="http://www.omg.org/spec/BPMN/20100524/DI"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	typeLanguage="http://www.w3.org/2001/XMLSchema">

	
	<!-- process definition -->
	<process id="27" name="myProcess">
		<startEvent id="1" name="start" >
			<extensionElements>
				<flowable:formProperty id="frm1" name="propName" type="string" />
			</extensionElements>
		</startEvent>
		<sequenceFlow id="10" name="fistStep" sourceRef="1" targetRef="scr1" />
		<scriptTask id="scr1" name="doScript" scriptType="text/x-groovy">
			<script>
		out:println 'hello'
		</script>
		</scriptTask>
		<userTask id="ut1" name="openDoor" >
			<documentation>
		some notes
		</documentation>
			<potentialOwner>
				<resourceAssignmentExpression>
					<formalExpression>will</formalExpression>
				</resourceAssignmentExpression>
			</potentialOwner
		</userTask>
		<sequenceFlow id="f_2" name="fistStep" sourceRef="scr1" targetRef="100" />
		<endEvent id="100" name="terminate" />
	</process>
</definitions>

Hi,

Sorry for the late response. The resource name is really important, because that is used in the Engine to determine which deployer should process the resource. So it should have a .bpmn (or .bpmn20.xml) extension for BPMN and for example .dmn for the DMN engine. If you don’t include a resource name, the resource will be ignored.

Best regards,

Tijs