Well, the unit test worked in the unit test only.
package org.activiti.designer.test; import java.util.HashMap; import java.util.Map; import org.activiti.engine.RuntimeService; import org.activiti.engine.test.Deployment; import org.activiti.engine.test.ActivitiRule; import org.junit.Rule; import org.junit.Test; public class ProcessTestHelloworld { @Rule public ActivitiRule activitiRule = new ActivitiRule(); @Test @Deployment(resources="diagrams/my_bpmn2_diagram.activiti.bpmn20.xml") public void startProcess() { RuntimeService runtimeService = activitiRule.getRuntimeService(); MapvariableMap = new HashMap (); variableMap.put("name", "Activiti"); variableMap.put("color", "BLUE"); runtimeService.startProcessInstanceByKey("helloworld", variableMap); } }
However, I don't know how to run it standalone.
I tried writing a main method that loads the same process.
Code:
package com.demo; import java.util.List; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngineConfiguration; import org.activiti.engine.task.Task; public class Demo { public static void main (String [] args) { ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration() .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE) .setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000") .setDatabaseSchemaUpdate("create-drop") .setJobExecutorActivate(true) .buildProcessEngine(); /* Deploy the xml file. */ processEngine.getRepositoryService() .createDeployment().addClasspathResource("diagrams/my_bpmn2_diagram.activiti.bpmn20.xml").deploy(); /* Start the process by id. */ processEngine.getRuntimeService().startProcessInstanceById("helloworld"); Listtasks = processEngine.getTaskService() .createTaskQuery().taskCandidateUser("fozzie").list(); System.out.println("Got some tasks " + tasks); for (Task task : tasks) { System.out.println(task.getId()); } } }
I get the same exception I was getting before (well similar).
Code:
Feb 1, 2011 5:08:47 PM org.activiti.engine.impl.ProcessEngineImplINFO: ProcessEngine default created Feb 1, 2011 5:08:47 PM org.activiti.engine.impl.jobexecutor.JobAcquisitionThread run INFO: JobAcquisitionThread starting to acquire jobs Feb 1, 2011 5:08:47 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy INFO: Processing resource diagrams/my_bpmn2_diagram.activiti.bpmn20.xml Feb 1, 2011 5:08:47 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes INFO: XMLSchema currently not supported as typeLanguage Feb 1, 2011 5:08:47 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes INFO: XPath currently not supported as expressionLanguage Feb 1, 2011 5:08:49 PM org.activiti.engine.impl.interceptor.CommandContext close SEVERE: Error while closing command context org.activiti.engine.ActivitiException: no deployed process definition found with id 'helloworld' at org.activiti.engine.impl.db.DbRepositorySession.findDeployedProcessDefinitionById(DbRepositorySession.java:217) at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:47) at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:29) at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:22) at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:37) at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33) at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:57) at com.demo.Demo.main(Demo.java:25) Exception in thread "main" org.activiti.engine.ActivitiException: no deployed process definition found with id 'helloworld' at org.activiti.engine.impl.db.DbRepositorySession.findDeployedProcessDefinitionById(DbRepositorySession.java:217) at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:47) at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:29) at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:22) at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:37) at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33) at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:57) at com.demo.Demo.main(Demo.java:25)
I want just a simple standalone example (that is not a unit test) that works.
BTW I did explore and try a few things with the unit test so I am not completely stuck.
Also the screenshots and generated code for the tutorial do not match the current plugin.
10 minute guide missing pieces.
Working tutorial with old screenshots.
Rick,
ReplyDeleteSeems like you're using runtimeService.startProcessInstanceById('helloWorld'), instead of startProcessInstanceByKey('helloWorld') as done in the unit-test above you won example...
I am deploying all *.bpmn20.xml file in one xml using deploymentResource with classpath,
ReplyDeleteIn this case Can I able to get the deployedId for all each *bpmn20.xml if YES how ..?
please help me out...