[jboss-user] [JBoss jBPM] - jbpm 3.2.2 in Jboss AS 4.2.2 - Transaction Problems

jaydub do-not-reply at jboss.com
Wed Feb 20 15:34:48 EST 2008


Hello,

I have recently added jBPM to some pre-existing EJB3 stateless session beans in my EE app, running on Jboss 4.2.2GA.    I must be doing something wrong, as I am unable to find any posts which seem to match my problem.   Hopefully this is not too difficult to troubleshoot, as jBPM is really going to be great addition to our app.    I have used http://wiki.jboss.org/wiki/Wiki.jsp?page=Jbpm32UsingCMT as a reference.

Here is my jbpm context config:

  <jbpm-context>
  |     <service name="persistence" factory="org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory" />
  |     <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
  |   </jbpm-context>

Hibernate config:

  | 
  | <hibernate-configuration>
  | 
  |   <session-factory>
  | 
  |     <!-- hibernate dialect -->
  |     <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
  | 
  |     <!-- Update DB Schema as needed -->
  |     <property name="hibernate.hbm2ddl.auto">update</property>
  | 
  |     <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
  | 
  |     <!-- DataSource properties (begin) -->
  |     <property name="hibernate.connection.datasource">java:/JbpmDS</property>
  |     <!-- DataSource properties (end) -->
  | 
  |     <!-- JTA transaction properties (begin) -->
  |     <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
  |     <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
  |      <!-- JTA transaction properties (end) -->
  | 
  | 
  | ...
  | ...

I am able to fetch/persist jBPM data with no problem.    Where I run into a problem is if I interact with jBPM, then try to persist my own entities via an entity manager from a different persistence context:

For example:


  |         
  | 
  |         JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  | 
  |         logger.debug("Starting a new PI in workflow " +
  |     	             procDefName + " for urlID=" + url.getUrlId());
  |     	try
  |     	{
  |     	    pi = jbpmContext.newProcessInstance(procDefName);
  |     	    pi.signal();
  |     	    jbpmContext.save(pi);
  |     	}
  |     	catch (Exception e)
  |     	{
  |     	    logger.error("Unable to start new PI for urlId=" + url.getUrlId() + 
  |     	    		     " in workflow " + procDefName, e);
  |     	    throw new EJBException(e);
  |     	}
  |     	finally
  |     	{
  |     	    jbpmContext.close();
  |     	}
  |         logger.debug("Started new jBPM process for urlId=" + url.getUrlId());
  |         
  |         // Need to track urlId -> PI, so persist the relationship.
  |         logger.debug("Saving process instance mapping.");
  |         ActiveProcessInstance activeProc = 
  |             new ActiveProcessInstance(url.getUrlId(), pi.getId(), workflowId, procDefName);
  |         em.persist(activeProc);

The final em.persist(activeProc)  call causes a TransactionRequiredException.    This operation saves the entity in a completely different database than jBPM is configured to use (same DB server though)    So in summary, I can execute the jBPM calls, or my own entity manager persist call, but not both inside the same stateless session bean method.   I did note that upon close, jBPM must be committing the JTA transaction, which causes the exception in the subsequent em.persist call.

2008-02-20 13:49:07,923 DEBUG [org.jbpm.svc.Services] org.jbpm.svc.Services.clo
  | se closing service 'persistence': org.jbpm.persistence.jta.JtaDbPersistenceServ
  | ice at 1026cfb
  | 2008-02-20 13:49:07,924 DEBUG [org.jbpm.persistence.db.DbPersistenceService] or
  | g.jbpm.persistence.db.DbPersistenceService.commit committing hibernate transact
  | ion org.hibernate.transaction.JTATransaction at 1143d35
  | 2008-02-20 13:49:07,925 DEBUG [org.jbpm.JbpmContext] org.jbpm.persistence.jta.J
  | taDbPersistenceService.endJtaTransaction end user JTA transaction
  | 2008-02-20 13:49:07,925 DEBUG [org.jbpm.JbpmContext] org.jbpm.persistence.jta.J
  | taDbPersistenceService.endJtaTransaction end jta transation with COMMIT
  | 2008-02-20 13:49:07,936 DEBUG [org.jbpm.svc.Services] org.jbpm.svc.Services.clo
  | se closing service 'tx': org.jbpm.tx.TxService at 141138b

I tried setting isTransactionEnabled to false for the persistence factory, but that did not seem to change anything.   Thanks for your help and sorry if I am missing something obvious.






View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4130910#4130910

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4130910



More information about the jboss-user mailing list