Data does not get inserted into BAMTaskSummary table in BPMS 6.0.x for standalone jBPM6 applications
Environment
- Red Hat JBoss BPM Suite (BPMS)
- 6.0.x
Issue
- There is a custom web application where
jBPM6
libraries are embedded inside it. The following is the wayRuntimeEngine
is configured in the code.
RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder();
EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence");
builder.entityManagerFactory(emf);
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
runtime = manager.getRuntimeEngine(EmptyContext.get());
The problem is no data is getting stored in BAMTaskSummary
table even after user has started some process which has user task
. Is there anything missing from configuration or code side?
Resolution
-
BAMTaskSummary
table in the database is populated by theorg.jbpm.services.task.audit.lifecycle.listeners.BAMTaskEventListener
class shipped withBPMS 6.0.x
. In order to enable the java code to use this class and populate theBAMTaskSymmary
table with the task data, users need to register thisTaskEventListener
class (i.e.BAMTaskEventListener
) as a Listener either atRuntimeManager
orTaskService
level. The following KCS solution How to implement Task Event Listeners in BPM Suite 6.0 ? shows how to do that using both the approaches for reference. -
User can also achieve the same as shown below.
package org.jbpm.services.task.audit.test;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.jbpm.services.task.HumanTaskServiceFactory;
import org.jbpm.services.task.audit.JPATaskLifeCycleEventListener;
import org.jbpm.services.task.audit.lifecycle.listeners.BAMTaskEventListener;
import org.junit.After;
import org.junit.Before;
import org.kie.internal.task.api.InternalTaskService;
import bitronix.tm.resource.jdbc.PoolingDataSource;
/**
*
*
*/
public class LocalLifeCycleTest extends LifeCycleBaseTest {
private PoolingDataSource pds;
private EntityManagerFactory emf;
@Before
public void setup() {
pds = setupPoolingDataSource();
emf = Persistence.createEntityManagerFactory( "org.jbpm.services.task" );
this.taskService = (InternalTaskService) HumanTaskServiceFactory.newTaskServiceConfigurator()
.entityManagerFactory(emf)
.listener(new JPATaskLifeCycleEventListener())
.listener(new BAMTaskEventListener())
.getTaskService();
}
...
- Even the following example would also work.
...
DefaultRegisterableItemsFactory registerableItemsFactory = new DefaultRegisterableItemsFactory();
registerableItemsFactory.addTaskListener(BAMTaskEventListener.class);
RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().registerableItemsFactory(registerableItemsFactory);
Diagnostic Steps
- First of all confirm if
BAMTaskEventListener
is registered atRuntimeManager
orTaskService
level or not. - Check if the following line is present inside
persistence.xml
file for the application or not.
<mapping-file>META-INF/TaskAuditorm.xml</mapping-file>
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments