07-24-2012 09:34 AM
<?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>
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());
}
}
07-24-2012 09:46 AM
07-24-2012 05:00 PM
Are you running from within eclipse? Make sure the "diagram" folder is on your class path (-> make it a source-folder).
07-25-2012 02:41 AM
07-25-2012 03:11 AM
Your process should be a "bpmn20.xml" file, instead of just a "bpmn" file, in order toz be picked up by the BPMNDeployer. If not, it will consider the file as "just another resource"…
You probably copied this from the designer unit-test, which adds the bpmn-file as a stream, naming it "myProcess.bpmn20.xml".
log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).
log4j:WARN Please initialize the log4j system properly.
Jul 25, 2012 12:38:09 PM org.activiti.engine.impl.ProcessEngineImpl <init>
INFO: ProcessEngine default created
Jul 25, 2012 12:38:09 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource diagrams/MyProcess.bpmn
Jul 25, 2012 12:38:09 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource MyProcess.bpmn20.xml
Jul 25, 2012 12:38:09 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XMLSchema currently not supported as typeLanguage
Jul 25, 2012 12:38:09 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XPath currently not supported as expressionLanguage
Jul 25, 2012 12:38:09 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource MyProcess.startProcess.png
Exception in thread "main" java.lang.NullPointerException
at com.sample.Demo.main(Demo.java:47)
package com.sample;
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) {
// Create Activiti process engine
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration().buildProcessEngine();
// Get Activiti services
RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
// Deploy the process definition
repositoryService.createDeployment().addClasspathResource("diagrams/MyProcess.bpmn").deploy();
// Start a process instance
runtimeService.startProcessInstanceByKey("startProcess");
TaskService taskService=processEngine.getTaskService();
Task task=taskService.createTaskQuery().taskAssignee("kermit").singleResult();
[b]System.out.println(task.getName());[/b]
}
}
07-25-2012 03:35 AM
.addInputStream("myProcess.bpmn20.xml, ReflectUtil.getResourceAsStream("myProcess.bpmn")
07-25-2012 04:05 AM
You should also RENAME the file to *.bpmn20.xml
OR
Add the file to the deployment this way:
.addInputStream("myProcess.bpmn20.xml, ReflectUtil.getResourceAsStream("myProcess.bpmn")
As I said, the engine only triggers process-parsing when resource NAME ends with bpmn20.xml
Exception in thread "main" org.activiti.engine.ActivitiException: resource 'diagrams/MyProcess.bpmn20.xml' not found
at org.activiti.engine.impl.repository.DeploymentBuilderImpl.addClasspathResource(DeploymentBuilderImpl.java:59)
at com.sample.Demo.main(Demo.java:41)
INFO: ProcessEngine default created
Exception in thread "main" org.activiti.engine.ActivitiException: inputStream for resource 'MyProcess.bpmn20.xml' is null
at org.activiti.engine.impl.repository.DeploymentBuilderImpl.addInputStream(DeploymentBuilderImpl.java:46)
at com.sample.Demo.main(Demo.java:41)
public static void main(String[] args) {
// Create Activiti process engine
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration().buildProcessEngine();
// Get Activiti services
RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
// Deploy the process definition
repositoryService.createDeployment().addClasspathResource("diagrams/MyProcess.bpmn").deploy();
// Start a process instance
runtimeService.startProcessInstanceByKey("startProcess");
TaskService taskService=processEngine.getTaskService();
Task task=taskService.createTaskQuery().taskAssignee("kermit").singleResult();
System.out.println(task.getName());
}
07-25-2012 04:15 AM
repositoryService.createDeployment().addInputStream("MyProcess.bpmn20.xml", ReflectUtil.getResourceAsStream("diagrams/MyProcess.bpmn")).deploy();
07-25-2012 04:18 AM
Try usingrepositoryService.createDeployment().addInputStream("MyProcess.bpmn20.xml", ReflectUtil.getResourceAsStream("diagrams/MyProcess.bpmn")).deploy();
10-29-2013 03:56 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.