AnsweredAssumed Answered

How to start a process by Standalone in Activiti

Question asked by sherlock on Jul 24, 2012
Latest reply on Jan 22, 2016 by jbarrez
Hi,
I am new to activiti. I am started exploring from few days.
I am using Activiti 5.9 and eclipse indigo and activiti 5.9.3 designer plugin.

When im trying to create a stand alone program to create a process and run. it's throwing an exception like
SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: no processes deployed with key 'startProcess'.

my MyProcess.bpmn code is like below

<?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" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="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="startProcess" name="Start process">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="User Task" activiti:assignee="kermit"></userTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_startProcess">
    <bpmndi:BPMNPlane bpmnElement="startProcess" id="BPMNPlane_startProcess">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="120" y="270"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55" width="105" x="200" y="260"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="360" y="270"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="155" y="287"></omgdi:waypoint>
        <omgdi:waypoint x="200" y="287"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="305" y="287"></omgdi:waypoint>
        <omgdi:waypoint x="360" y="287"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>



and my simple java program is like.



import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;



public class Demo {
public static void main(String[] args) {
   
   ProcessEngine processEngine=ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration().buildProcessEngine();
   
   RepositoryService repositoryService=processEngine.getRepositoryService();
   repositoryService.createDeployment().addClasspathResource("diagrams/MyProcess.bpmn").deploy();
   
   RuntimeService runtimeService=processEngine.getRuntimeService();
   ProcessInstance processInstance=runtimeService.startProcessInstanceByKey("startProcess");
   
   TaskService taskService=processEngine.getTaskService();
   Task task=taskService.createTaskQuery().taskAssignee("kermit").singleResult();

   System.out.println(task.getName());
}
}



so please help me what is the wrong in my code.


Thanks
Sherlock

Outcomes