部署后Camunda ProcessDefinition不可用

时间:2016-06-24 12:26:18

标签: java deployment bpmn camunda

我有一个Camunda 7.3独立的h2-in-mem配置,我希望将其集成到我自己的应用程序中。当我基于(有效的)bpmn xml String创建部署时,我得不到任何流程定义:

public String deployProcess(WorkflowDef workflowDef) throws IOException, SQLException {
    //prepare resources
    String name = workflowDef.getTitle()+".bpmn";
    InputStream stream = new ByteArrayInputStream(workflowDef.getBpmnXml().getBytes(Charset.defaultCharset()));

    //prepare deployment
    RepositoryService repositoryService = processEngine.getRepositoryService();
    final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
    deploymentBuilder.name(workflowDef.getId());
    DeploymentEntity deploymentResult;

    try {
        deploymentResult = (DeploymentEntity) repositoryService.createDeployment().addInputStream(name, stream).deploy();
    } finally {
        stream.close();
    }

    //read the result
    String deploymentId = deploymentResult.getId();
    ProcessDefinition processDef = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();

    //return the process definition id for later query
    String processDefinitionId = processDef.getId();
    return processDefinitionId;
}

注意:对象workflowDef只是一个包装器,它包含bpmn.io建模器中的定义,如name和bpmn XML作为String。我还确保,引擎和数据库已初始化并正在运行。

部署后,我在

行得到一个NullPointerException
String processDefinitionId = processDef.getId();

即使我试图通过

获得定义
repositoryService.createProcessDefinitionQuery().list();

我刚收到一个空列表。我的代码中有误解吗?

0 个答案:

没有答案