4
votes

I'm trying to deploy a process definition from a file using the following code

    DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().name(definitionName);
    deploymentBuilder.addInputStream(definitionName, definitionFileInputStream);
    String deploymentId = deploymentBuilder.deploy().getId();
    System.out.println(deploymentId);

The above code runs successfully and the new deploymentId is printed out.

Later, I tried to list the deployed process definitions using the following code

    List<ProcessDefinition> definitions = repositoryService.createProcessDefinitionQuery().list();
    System.out.println(definitions.size());

The above code runs successfully but the output is always 0.

I've done some investigations and found that in the ACT_GE_BYTEARRAY table an entry with the corresponding deploymentId exists and the BYTES_ column contains that contents of the definitions file.

I have also found that there is no corresponding entry found in ACT_RE_PROCDEF table.

Is there something messing? from the API and the examples I found it seems that the above code shall suffice, or is there a missing step?

Thanks for your help

2

2 Answers

5
votes

It turned out that the issue was related to definitionName (thanks thorben!) as it has to ends on either .bpmn20.xml or .bpmn.

After further testing, the suffix is required for the following definitionName of the code

    deploymentBuilder.addInputStream(definitionName, definitionFileInputStream);

Leaving the following definitionName without the suffix is fine

    repositoryService.createDeployment().name(definitionName);
2
votes

It seems that you forget the isExecutable flag on your deployed process definitions. Please check if your process model contains a isExecutable flag. If you use the camunda modeler simply set this option in the properties panel of the process.

If you call #deploy() with non-executable definitions an deployment will created, but the process definition are not deployed since they are not executable.

On the latest version of camunda platform (7.7), a new method called #deployWithResult() was added to the DeploymentBuilder. This method returns the deployed process definitions, so it is easy to check if process definitions are deployed.