cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatic deployment --> process definition not detected

mtaal
Champ in-the-making
Champ in-the-making
Hi,
I am programmatically deploying a bpmn definition (the vacation request example). The deployment is visible in the admin ui of the explorer, but no processdefinition is created. I can see that the xml is there. If I upload directly in the UI then the process definition is found.

I checked and I do exactly the same as the auto deployment code in the SpringProcessEngineConfiguration code.

I run my code (see below) in the ContextListener.contextInitialized method. Should I do an explicit commit somehow? Or something else? (I do .deploy after adding input streams)

Thanks!

gr. Martin

        String deploymentName;
        if (workFlow.getModule().isInDevelopment()) {
          deploymentName = workFlow.getName() + "_" + System.currentTimeMillis();
        } else {
          deploymentName = workFlow.getName() + "_" + workFlow.getModule().getVersion();
        }
        deploymentName += ".bpnm20.xml";
        final Deployment deployment = repositoryService.createDeploymentQuery()
            .deploymentName(deploymentName).singleResult();
        if (deployment == null) {
          final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment()
              .enableDuplicateFiltering().name(deploymentName);
          if (workFlow.getImagePath() != null) {
            deploymentBuilder.addInputStream(workFlow.getImagePath(), this.getClass()
                .getResourceAsStream("/" + workFlow.getImagePath()));
          }
          deploymentBuilder.addInputStream(deploymentName, new ByteArrayInputStream(workFlow
              .getWorkflow().getBytes("UTF-8")));
          deploymentBuilder.deploy();
        }
5 REPLIES 5

mtaal
Champ in-the-making
Champ in-the-making
Ok, a typo from my side, the resource containing the bpmn definition should have the correct suffix:
.bpmn20.xml

then it is parsed correctly.

gr. Martin

ayseyo
Champ in-the-making
Champ in-the-making
Hi, I have exactly the same problem.
I am trying to deploy a process programmatically via my application and I see a 'Nameless Deployment' at activiti-explorer and when I query ACT_RE_DEPLOYMENT table, there is this row :

ID_        NAME_   CATEGORY_ DEPLOY_TIME_
32813 NULL   NULL                2014-10-02 14:28:20.463

But there is nothing added to ACT_RE_PROCDEF table related with my deployed process.

Here is my code to deploy process
—————————————————————————-
@Override
public void createDeployment(byte[] bytes) {
  XMLStreamReader xtr = null;
  ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
  try {
   xtr = XMLInputFactory.newInstance().createXMLStreamReader(bis);
  } catch (Exception e) {
   throw new ApplicationException(e.getMessage());
  }
  BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
 
  repositoryService.createDeployment().addBpmnModel("loan", bpmnModel).deploy();
}
——————————————————————————

I want to get the process (which will be deployed) from user input via screen, so parameter of function is "byte[] bytes".

I have also tried this code just to understand and investigate about programmatic process deployment but this gave me the same results:

———————————————————————————————————-
try {
   repositoryService.createDeployment()
     .addInputStream("xxx", new FileInputStream(new File("D:/Repos2/gelisk/process/src/main/resources/diagramsCreateOrgCustomerProcess.bpmn"))).deploy();
  } catch (Exception e) {
   throw new ApplicationException(e.getMessage());
  }

  runtimeService.startProcessInstanceByKey("createOrgCustomer");
———————————————————————————————————


Am I doing something wrong ?
Any help would be appreciated, thanks..

martin_grofcik
Confirmed Champ
Confirmed Champ
Could you share your process definition?

ayseyo
Champ in-the-making
Champ in-the-making
Hi, sorry for the delay, I've been on a holiday.
Process definition is confidential information to the company that I work. But I've created a simple process diagram below, and I've experienced same problem. You can look at the process definition below.

I wanted to attach screen shot from activiti-explorer but I couldn't, only txt files are permitted I guess ???


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <userTask id="getLoanData_UT" name="Collect Loan Data"></userTask>
    <serviceTask id="validateLoan_ST" name="Validate Loan"></serviceTask>
    <userTask id="modifyLoan_UT" name="Modify Loan"></userTask>
    <serviceTask id="updateLoan_ST" name="Update Loan"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="getLoanData_UT"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="getLoanData_UT" targetRef="validateLoan_ST"></sequenceFlow>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow3" sourceRef="validateLoan_ST" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="exclusivegateway1" targetRef="modifyLoan_UT"></sequenceFlow>
    <sequenceFlow id="flow5" sourceRef="exclusivegateway1" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="updateLoan_ST" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow7" sourceRef="modifyLoan_UT" targetRef="updateLoan_ST"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
    <bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="120.0" y="183.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="840.0" y="183.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="getLoanData_UT" id="BPMNShape_getLoanData_UT">
        <omgdc:Bounds height="61.0" width="105.0" x="240.0" y="170.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="validateLoan_ST" id="BPMNShape_validateLoan_ST">
        <omgdc:Bounds height="61.0" width="105.0" x="470.0" y="170.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="modifyLoan_UT" id="BPMNShape_modifyLoan_UT">
        <omgdc:Bounds height="55.0" width="105.0" x="608.0" y="320.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="updateLoan_ST" id="BPMNShape_updateLoan_ST">
        <omgdc:Bounds height="55.0" width="105.0" x="805.0" y="320.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="640.0" y="180.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="155.0" y="200.0"></omgdi:waypoint>
        <omgdi:waypoint x="240.0" y="200.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="345.0" y="200.0"></omgdi:waypoint>
        <omgdi:waypoint x="470.0" y="200.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="575.0" y="200.0"></omgdi:waypoint>
        <omgdi:waypoint x="640.0" y="200.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="660.0" y="220.0"></omgdi:waypoint>
        <omgdi:waypoint x="660.0" y="320.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="680.0" y="200.0"></omgdi:waypoint>
        <omgdi:waypoint x="840.0" y="200.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="910.0" y="347.0"></omgdi:waypoint>
        <omgdi:waypoint x="857.0" y="316.0"></omgdi:waypoint>
        <omgdi:waypoint x="857.0" y="218.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="713.0" y="347.0"></omgdi:waypoint>
        <omgdi:waypoint x="805.0" y="347.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

jbarrez
Star Contributor
Star Contributor
Put it somewhere on https://gist.github.com/ 🙂