jnorris [
https://community.jboss.org/people/jnorris] created the discussion
"Re: abortProcessInstance causes an exception"
To view the discussion, visit:
https://community.jboss.org/message/783484#783484
--------------------------------------------------------------
Hi Maciej,
We have a set of cxf web services that interface to the jbpm runtime. We are not using
any of the jbpm web apps and are running in an osgi container. When the web services is
invoked a setup method gets a bean that has the jbpm api calls. A setup method creates
the session. When the method being called returns a cleanup method disposes of the
session. I would have attached a zip with the log and some code but I don't see any
way to do that so I'll add it in the reply. This is the spring configuration in
blueprint.xml:
<bean id="jtaTransactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager"
ref="transactionManager"/>
<property name="userTransaction"
ref="userTransaction"/>
</bean>
<bean id="htTxMgr"
class="org.drools.container.spring.beans.persistence.HumanTaskSpringTransactionManager"
scope="prototype">
<argument ref="jtaTransactionManager" />
</bean>
<bean id="systemEventListener"
class="org.drools.SystemEventListenerFactory"
factory-method="getSystemEventListener" />
<bean id="taskService" class="org.jbpm.task.service.TaskService"
scope="prototype">
<property name="systemEventListener"
ref="systemEventListener" />
</bean>
<bean id="taskSessionFactory"
class="org.jbpm.task.service.persistence.TaskSessionSpringFactoryImpl"
init-method="initialize" depends-on="taskService"
scope="prototype">
<property name="transactionManager" ref="htTxMgr" />
<property name="useJTA" value="true" />
<property name="taskService" ref="taskService" />
<jpa:unit unitname="org.jbpm.persistence.jpa"
property="entityManagerFactory"/>
</bean>
<bean id="provider.jbpm.api.interaction"
class="com.test.jbpm.JbpmApiInteraction"
init-method="setup" scope="prototype">
<property name="transactionManager"
ref="jtaTransactionManager" />
<property name="taskSessionFactory"
ref="taskSessionFactory" />
<jpa:unit unitname="org.jbpm.persistence.jpa"
property="entityManagerFactory"/>
</bean>
The setup method in the bean does the following:
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, this.entityManagerFactory );
env.set( EnvironmentName.GLOBALS, new MapGlobalResolver() );
AbstractPlatformTransactionManager aptm = (AbstractPlatformTransactionManager)
transactionManager;
TransactionManager transactionManager = new DroolsSpringTransactionManager( aptm );
env.set( EnvironmentName.TRANSACTION_MANAGER, transactionManager );
PersistenceContextManager persistenceContextManager = new DroolsSpringJpaManager( env );
env.set( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, persistenceContextManager );
Properties properties = new Properties();
properties.put( "drools.processInstanceManagerFactory",
"org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory" );
properties.put( "drools.processSignalManagerFactory",
"org.jbpm.persistence.processinstance.JPASignalManagerFactory" );
KnowledgeSessionConfiguration config =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration( properties );
ksession = JPAKnowledgeService.newStatefulKnowledgeSession( this.kbase, config, env );
this.ksession.getWorkItemManager().registerWorkItemHandler( "Service Task", new
ServiceTaskHandler() );
this.taskSession = taskSessionFactory.createTaskServiceSession();
taskService = this.taskSession.getService();
localTaskService = new LocalTaskService( taskService );
CustomSyncWsWorkItemHandler humanTaskHandler = new CustomSyncWsWorkItemHandler(
this.localTaskService, this.ksession );
humanTaskHandler.setLocal( true );
humanTaskHandler.connect();
this.ksession.getWorkItemManager().registerWorkItemHandler( "Human Task",
humanTaskHandler );
this.ksession.addEventListener( new ProcessEventListenerImpl());
TasksAdmin admin = taskService.createTaskAdmin();
this.ksession.addEventListener( new TaskCleanUpProcessEventListener( admin ));
Note: the CustomSyncWsWorkItemHandler is related to issue JBPM-3578. We need this because
we also are supporting BRMS5.3.0.
The bean is created:
jbpmApiInteraction = (JbpmApiInteraction)blueprintContainer.getComponentInstance(
"provider.jbpm.api.interaction" );
The method to cancel the process instance is invoked on the bean:
jbpmApiInteraction.cancelProcessInstance( instanceId ) calls
this.ksession.abortProcessInstance( instanceId )
After the call returns the objects are disposed in the bean:
this.taskSession.dispose();
this.localTaskService.dispose();
this.kession.dispose();
I'll post the stack trace in another reply.
Regards,
Jim
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/783484#783484]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]