I am trying to make a simple Hello world application using Activiti 5.13 BPMN. I made a dynamic web application project in eclipse and added my hello_world.bpmn diagram to the root folder and my test.java and activiti.cfg.xml files to the src folder. The application is just suppose to print "Hello, world" to the console, but I cannot seem to get it to do this. Below if all the files that I am using to run the application, also I am using a PostgreSQL database (I created all the necessary tables)
My hello_world.bpmn file is as following:
start event - > user script (groovy) - > end event
<?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="myProcess" name="My process" isExecutable="true">
<startEvent id="startProcess" name="Start"></startEvent>
<scriptTask id="scriptProcess" name="Hello world" scriptFormat="groovy" activiti:autoStoreVariables="true">
<script>System.out.println("Hello, world this is the activiti process")</script>
</scriptTask>
<endEvent id="endProcess" name="End"></endEvent>
<sequenceFlow id="flow1" sourceRef="startProcess" targetRef="scriptProcess"></sequenceFlow>
<sequenceFlow id="flow2" sourceRef="scriptProcess" targetRef="endProcess"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
<bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
<bpmndi:BPMNShape bpmnElement="startProcess" id="BPMNShape_startProcess">
<omgdc:Bounds height="35.0" width="35.0" x="110.0" y="220.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="scriptProcess" id="BPMNShape_scriptProcess">
<omgdc:Bounds height="55.0" width="105.0" x="210.0" y="210.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endProcess" id="BPMNShape_endProcess">
<omgdc:Bounds height="35.0" width="35.0" x="390.0" y="220.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="145.0" y="237.0"></omgdi:waypoint>
<omgdi:waypoint x="210.0" y="237.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="315.0" y="237.0"></omgdi:waypoint>
<omgdi:waypoint x="390.0" y="237.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
My activiti.cfg.xml file is as following:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans ;
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- Database configurations -->
<property name="databaseType" value="postgres" />
<property name="jdbcUrl" value="jdbc:postgresql://localhost:5432/postgres" />
<property name="jdbcDriver" value="org.postgresql.Driver" />
<property name="jdbcUsername" value="user1234" />
<property name="jdbcPassword" value="password1234" />
</bean>
</beans>
My test.java file is as following:
public class test {
public static void main(String[] args) {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RuntimeService runtimeService = processEngine.getRuntimeService();
RepositoryService repositoryService = processEngine.getRepositoryService();
TaskService taskService = processEngine.getTaskService();
ManagementService managementService = processEngine.getManagementService();
IdentityService identityService = processEngine.getIdentityService();
HistoryService historyService = processEngine.getHistoryService();
FormService formService = processEngine.getFormService();
runtimeService.startProcessInstanceByKey("myProcess");
System.out.println("PRINT THIS MESSAGE");
}
}
When I run the application on my tomcat server I get the following results:
11:34:14,359 [localhost-startStop-1] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
11:34:14,578 [localhost-startStop-1] INFO org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Wed Aug 21 11:34:14 CDT 2013]; root of context hierarchy
11:34:14,750 [localhost-startStop-1] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
11:34:14,890 [localhost-startStop-1] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/activiti-standalone-context.xml]
11:34:14,953 [localhost-startStop-1] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/activiti-ui-context.xml]
11:34:15,328 [localhost-startStop-1] INFO org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from class path resource [db.properties]
11:34:15,343 [localhost-startStop-1] INFO org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from class path resource [ui.properties]
11:34:15,437 [localhost-startStop-1] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@caa278: defining beans [demoDataGenerator,dbProperties,dataSource,transactionManager,processEngineConfiguration,processEngine,repositoryService,runtimeService,taskService,historyService,managementService,identityService,activitiLoginHandler,activitiUiPropertyPlaceholder,navigatorManager,attachmentRendererManager,formPropertyRendererManager,variableRendererManager,componentFactories,processDefinitionFilterFactory,deploymentFilterFactory,navigationFragmentChangeListener,mainWindow,explorerApp,i18nManager,scopedTarget.messageSource,messageSource,notificationManager,viewManager,workflowDefinitionConversionFactory]; root of factory hierarchy
11:34:19,531 [localhost-startStop-1] INFO org.activiti.engine.impl.ProcessEngineImpl - ProcessEngine default created
11:34:19,531 [localhost-startStop-1] INFO org.activiti.engine.impl.jobexecutor.JobExecutor - Starting up the JobExecutor[org.activiti.engine.impl.jobexecutor.DefaultJobExecutor].
11:34:19,531 [Thread-1] INFO org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable - JobExecutor[org.activiti.engine.impl.jobexecutor.DefaultJobExecutor] starting to acquire jobs
11:34:19,546 [localhost-startStop-1] INFO org.activiti.explorer.demo.DemoDataGenerator - Initializing demo groups
11:34:19,765 [localhost-startStop-1] INFO org.activiti.explorer.demo.DemoDataGenerator - Initializing demo users
11:34:19,921 [localhost-startStop-1] INFO org.activiti.explorer.demo.DemoDataGenerator - Initializing demo process definitions
11:34:19,937 [localhost-startStop-1] INFO org.activiti.explorer.demo.DemoDataGenerator - Initializing demo models
11:34:19,953 [localhost-startStop-1] INFO org.activiti.explorer.demo.DemoDataGenerator - Initializing demo report data
11:34:19,953 [Thread-2] INFO org.activiti.engine.impl.jobexecutor.JobExecutor - Shutting down the JobExecutor[org.activiti.engine.impl.jobexecutor.DefaultJobExecutor].
11:34:19,953 [Thread-1] INFO org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable - JobExecutor[org.activiti.engine.impl.jobexecutor.DefaultJobExecutor] stopped job acquisition
11:34:20,281 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/VacationRequest.png
11:34:20,281 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/FixSystemFailureProcess.bpmn20.xml
11:34:20,484 [localhost-startStop-1] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 6109 ms
Aug 21, 2013 11:34:20 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Aug 21, 2013 11:34:20 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Aug 21, 2013 11:34:20 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 15043 ms
11:34:21,250 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/FixSystemFailureProcess.png
11:34:21,250 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/VacationRequest.bpmn20.xml
11:34:21,421 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/createTimersProcess.bpmn20.xml
11:34:21,484 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/simple-approval.simpleApprovalProcess.png
11:34:21,484 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/reviewSalesLead.bpmn20.xml
11:34:21,593 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/reviewSalesLead.reviewSaledLead.png
11:34:21,593 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/Helpdesk.png
11:34:21,593 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/Helpdesk.bpmn20.xml
11:34:21,656 [Thread-2] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/explorer/demo/process/simple-approval.bpmn20.xml
11:34:36,953 [Thread-2] INFO org.activiti.engine.impl.jobexecutor.JobExecutor - Starting up the JobExecutor[org.activiti.engine.impl.jobexecutor.DefaultJobExecutor].
11:34:36,953 [Thread-2] INFO org.activiti.explorer.demo.DemoDataGenerator - Demo report data generated
11:34:36,953 [Thread-4] INFO org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable - JobExecutor[org.activiti.engine.impl.jobexecutor.DefaultJobExecutor] starting to acquire jobs
What's here looks OK. Have you looked in the activiti explorer to make sure your process deployed properly? You can exercise your process in the explorer too. This serves as a sanity check before you start using it in your code.
That process name looks a little funny. Normally when you deploy a process to activiti via the explorer, it appends a version number to the process name like "myProcess:23". This extended name is what you use to instantiate the process.