Activiti listeners not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2012 06:14 AM
I am trying to catch all the events for a process running on the Activiti explorer. I have implemented the bpmnparselistener class and moved my handler classes as Jars file to the WEB-INF/lib folder (ParseListener.jar). I have uploaded my process to the explorer using the bar file. However. no events are generated for the deployed process i.e. start event. I think It is my code below, which i am not sure where to put. Currently, it is in \webapps\activiti-explorer\WEB-INF\applicationContext.xml. I tried embedding the Listener with in the BPMN xml file and it worked but look like the Activiti can not read when using BPMNParseListener (implemented). It doesn't raise any exceptions or errors. My understanding is that Activiti engine automatically understand the customPostBPMNParseListeners property and there is nothing to declare in the process itself
<property name="customPostBPMNParseListeners"> <list> <bean class="org.handler.ParseListener"></bean> </list> </property>
Any help would be highly appreciated
thanks,
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2013 05:05 PM
What did you implement in the BpmnParseListener?
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 05:33 AM
I tried to Implement the BpmnParseListener like the HistoryParseListner class. I have a method (addActivityHandlers()-shown below) with in the BpmnParseListener that is called from different parse events for example;
public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {addActivityHandlers(activity);
}
addActivityHandlers(ActivityImpl activity) {
activity.addExecutionListener(PvmEvent.EVENTNAME_START, ACTIVITY_INSTANCE_START_LISTENER, 0);
activity.addExecutionListener(PvmEvent.EVENTNAME_END, ACTIVITY_INSTANCE_END_LISTENER);
}
I also have my handler classes to catch the events. They are separate classes for example: ActivityInstanceStartHandler, ActivityInstanceEndHandler.
I have tested this application offline with unit Testing and it works perfectly but it is not working on server or activiti explorer to generate live events.
thanks,
Kind regards,
Logic3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 05:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 05:58 AM

many thanks
applicationContext.xml file:
<context:annotation-config />
<bean id="dbProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:db.properties" />
<!– Allow other PropertyPlaceholderConfigurer to run as well –>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
<bean id="demoDataGenerator" class="org.activiti.explorer.demo.DemoDataGenerator">
<property name="processEngine" ref="processEngine" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="defaultAutoCommit" value="false" />
</bean>
<!– <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/activiti?autoReconnect=true" />
<property name="username" value="activiti" />
<property name="password" value="activiti" />
<property name="defaultAutoCommit" value="false" />
</bean> –>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="true" />
<property name="customFormTypes">
<list>
<ref bean="userFormType"/>
</list>
</property>
<!– My Listener –>
<property name="customPostBPMNParseListeners">
<list>
<bean class="org.bpmnwithactiviti.handler.ParseListener"></bean>
</list>
</property>
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean" destroy-method="destroy">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
<bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
<bean id="activitiLoginHandler" class="org.activiti.explorer.ui.login.DefaultLoginHandler">
<property name="identityService" ref="identityService" />
</bean>
<!– Include the UI-related wiring. This UI context will be used in the alfresco activiti admin UI –>
<import resource="activiti-ui-context.xml" />
<!– Custom form types –>
<bean id="userFormType" class="org.activiti.explorer.form.UserFormType"/>
</beans>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 07:43 AM
That configuration looks good. You said that it worked outside of tomcat, how did you test that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 08:06 AM
I really can't figure out why it is not working. Below you can find my applicationcontext file for offline testing. It offers engine configuration, deploy the process and contain the BPMNParseListner property. I then used the "@ContextConfiguration("classpath:listener/application-context.xml")" with in my tester.java file which simply run the process using "ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");". For unit testing, the running process successfully throws out events.
<bean id="dataSource"
class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
<property name="targetDataSource">
<bean class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="org.h2.Driver" />
<property name="url" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="databaseType" value="h2" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<!– Deploy BPMN process –>
<property name="deploymentResources"
value="classpath*:listener/processEventListener.bpmn20.xml" />
<property name="history" value="full" />
<property name="jobExecutorActivate" value="false" />
<!– My Listener –>
<property name="customPostBPMNParseListeners">
<list>
<bean class="org.bpmnwithactiviti.handler.ParseListener"></bean>
</list>
</property>
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<bean id="repositoryService" factory-bean="processEngine"
factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine"
factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine"
factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine"
factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine"
factory-method="getManagementService" />
</beans>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 09:35 AM
Because it *could* be that the wrong default-process-engine has been initialized BEFORE, so the one that your spring-context fires up, is not registered as default. All explorer-app code uses ProcessEngines.getDefaultProcessEngine() to obtain a process-engine.
So the presence of a activiti.cfg.xml-file will cause that engine to be used, while all other parts (UI, …) are taken from spring.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 10:05 AM
Could you please advise how to fix this so that the activiti explorer start throwing events?
cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 10:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 10:26 AM

You were right. I had to delete the activiti-cfg.jar from tomcat/lib.
Thanks again.
