[jboss-dev-forums] [Design of JBoss jBPM] - possible bug with JTA transactions

camunda do-not-reply at jboss.com
Mon May 7 08:59:20 EDT 2007


Hi,

I am not yet sure if it is a bug or a missconfiguration from me. But I am nearly convinced that it is a bug ;-)

I use the JtaDbPersistenceServiceFactory for pesisting (transactionEnabled=true, currentSessionEnabled=true). Now I trigger a process with a small action, which queries process name from jbpm (and therefor create a own jbpmContext). My testcode:


  | 	private String testProcess = "<process-definition name='Test'>"
  | 	 + "<start-state name='startState'>"
  | 	 + " <transition name='startTransactionTest' to='end'>"
  | 	 + "  <action name='test' class='com.camunda.ccs.process.test.ExecuteJbpmCommand'/>"
  | 	 + " </transition>"
  | 	 + "</start-state>"
  | 	 + "<end-state name='end'/>"
  | 	 + "</process-definition>";
  | 	
  | 	public void testHibernateSession() {
  | 		// deploy process
  | 		DeployProcessCommand deployCmd = new DeployProcessCommand();
  | 		deployCmd.setXml( testProcess );
  | 		Tk4jbpmConfiguration.getCommandService().execute(deployCmd);
  | 		
  | 		// now start it
  | 		StartProcessInstanceCommand cmd = new StartProcessInstanceCommand();
  | 		cmd.setProcessName("test");
  | 		ProcessInstance pi = (ProcessInstance) Tk4jbpmConfiguration.getCommandService().execute(cmd);
  | 	
  | 		// process is ended
  | 		assertNotNull(pi.getEnd());
  | 	}
  | 
(The Tk4jbpmConfiguration.getCommandService() just gets a reference to a EJB-3-ServiceBean, which runs the execute in TransactionAttributeType.REQUIRED).

The aciton is very easy:

  | public class ExecuteJbpmCommand implements ActionHandler {
  | 	public void execute(ExecutionContext ctx) throws Exception {		
  | 		GetProcessDefinitionCommand cmd = new GetProcessDefinitionCommand();
  | 		Tk4jbpmConfiguration.getCommandService().execute(cmd);
  | 	}
  | }
  | 

Now I get the following problem: The first context starts a transaction (and gets the current user transaction from hibrnate). The second jbpmContext get the same transaction. But it commits & closes it at the end (the commit has of xourse no effect on the JTA-Transaction, but the begun marker of the hibernate JTATransaction is set to false!). After that, we get a Exception while closing the JTATransaction the second time. If we ignore it, everything seems to work fine.

You can also see that in the logs:

anonymous wrote : 
  | DEBUG [org.jbpm.JbpmContext] creating org.jbpm.JbpmContext at 27e905
  | DEBUG [com.camunda.toolkit.jbpm.service.CommandServiceBean] executing org.jbpm.command.StartProcessInstanceCommand at 336f59...
  | DEBUG [org.jbpm.persistence.db.DbPersistenceService] using current hibernate session SessionImpl(...)
  | DEBUG [org.jbpm.persistence.db.DbPersistenceService] beginning hibernate transaction
  | DEBUG [org.hibernate.transaction.JTATransaction] Looking for UserTransaction under: UserTransaction
  | DEBUG [org.hibernate.transaction.JTATransaction] Obtained UserTransaction
  | DEBUG [org.hibernate.transaction.JTATransaction] begin
  | DEBUG [org.jbpm.persistence.db.DbPersistenceService] begun hibernate transaction org.hibernate.transaction.JTATransaction at d34b8c
  | 
  |   DEBUG [org.jbpm.configuration.JbpmContextInfo] creating jbpm context with service factories '[message, tx, scheduler, authentication, persistence, logging]'
  |   DEBUG [org.jbpm.JbpmContext] creating org.jbpm.JbpmContext at 12f2476
  |   DEBUG [com.camunda.toolkit.jbpm.service.CommandServiceBean] executing org.jbpm.command.GetProcessDefinitionCommand at 2fe28...
  |   DEBUG [org.jbpm.persistence.db.DbPersistenceService] using current hibernate session SessionImpl(...)
  |   DEBUG [org.jbpm.persistence.db.DbPersistenceService] beginning hibernate transaction
  |   DEBUG [org.jbpm.persistence.db.DbPersistenceService] begun hibernate transaction org.hibernate.transaction.JTATransaction at d34b8c
  |   DEBUG [com.camunda.toolkit.jbpm.service.CommandServiceBean] ... finished with org.jbpm.command.GetProcessDefinitionCommand at 2fe28
  |   DEBUG [org.jbpm.JbpmContext] closing org.jbpm.JbpmContext at 12f2476
  |   DEBUG [org.jbpm.svc.Services] closing service 'persistence': org.jbpm.persistence.jta.JtaDbPersistenceService at 1d6c90d
  |   DEBUG [org.jbpm.persistence.db.DbPersistenceService] committing hibernate transaction org.hibernate.transaction.JTATransaction at d34b8c
  |   DEBUG [org.hibernate.transaction.JTATransaction] commit
  | 
  | DEBUG [com.camunda.toolkit.jbpm.service.CommandServiceBean] ... finished with org.jbpm.command.StartProcessInstanceCommand at 336f59
  | DEBUG [org.jbpm.JbpmContext] closing org.jbpm.JbpmContext at 27e905
  | DEBUG [org.jbpm.svc.Services] closing service 'persistence': org.jbpm.persistence.jta.JtaDbPersistenceService at 383c13
  | DEBUG [org.jbpm.persistence.db.DbPersistenceService] committing hibernate transaction org.hibernate.transaction.JTATransaction at d34b8c
  | ERROR [org.jbpm.persistence.db.DbPersistenceService] hibernate commit failed
  | org.hibernate.TransactionException: Transaction not successfully started
  | 	at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:126)
  | 	at org.jbpm.persistence.db.DbPersistenceService.commit(DbPersistenceService.java:255)
  | 	at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:213)
  | 	at org.jbpm.persistence.jta.JtaDbPersistenceService.close(JtaDbPersistenceService.java:34)
  | 	at org.jbpm.svc.Services.close(Services.java:222)
  | 	at org.jbpm.JbpmContext.close(JbpmContext.java:139)
  | 	at com.camunda.toolkit.jbpm.service.CommandServiceBean.execute(CommandServiceBean.java:91)
  | 

Now, what is the right way to handle it? I am not completly sure at this point...

Any remarks?

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

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



More information about the jboss-dev-forums mailing list