2 Replies Latest reply on Jan 20, 2007 9:57 AM by kukeltje

    JBPMContext.close cause Exception

    nib

      Hi,
      I am using jBPM 3.2 Alpha 2 and trying to start the a process from an ejb3 messagedrivenbean by:

       private void kickOffProcess(String processname, String [] attrnames, java.io.Serializable[] attrvalues) {
       org.jbpm.JbpmConfiguration jbpmConfiguration = org.jbpm.JbpmConfiguration.parseXmlString(
       "<jbpm-configuration>" +
      
       // A jbpm-context mechanism separates the jbpm core
       // engine from the services that jbpm uses from
       // the environment.
       "<jbpm-context>"+
       "<service name='persistence' factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />"+
       "<service name='tx' factory='org.jbpm.tx.TxServiceFactory' />"+
       "<service name='message' factory='org.jbpm.msg.db.DbMessageServiceFactory' />" +
       "<service name='scheduler' factory='org.jbpm.scheduler.db.DbSchedulerServiceFactory' />"+
       "<service name='logging' factory='org.jbpm.logging.db.DbLoggingServiceFactory' />"+
       "<service name='authentication' factory='org.jbpm.security.authentication.DefaultAuthenticationServiceFactory' />"+
       "</jbpm-context>"+
      
       // configuration property used by persistence service impl org.jbpm.persistence.db.DbPersistenceServiceFactory
       "<string name='resource.hibernate.cfg.xml' value='config/hibernate.cfg.xml' />"+
      
       // <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->
       "<string name='resource.business.calendar' value='org/jbpm/calendar/jbpm.business.calendar.properties' />"+
       "<string name='resource.default.modules' value='org/jbpm/graph/def/jbpm.default.modules.properties' />"+
       "<string name='resource.converter' value='org/jbpm/db/hibernate/jbpm.converter.properties' />"+
       "<string name='resource.action.types' value='org/jbpm/graph/action/action.types.xml' />"+
       "<string name='resource.node.types' value='org/jbpm/graph/node/node.types.xml' />"+
       "<string name='resource.parsers' value='org/jbpm/jpdl/par/jbpm.parsers.xml' />"+
       "<string name='resource.varmapping' value='org/jbpm/context/exe/jbpm.varmapping.xml' />"+
       "<string name='resource.mail.templates' value='jbpm.mail.templates.xml' />"+
      
       "<int name='jbpm.byte.block.size' value='1024' singleton='true' />"+
       "<string name='jbpm.mail.smtp.host' value='localhost' />"+
       "<bean name='jbpm.task.instance.factory' class='org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl' singleton='true' />"+
       "<bean name='jbpm.variable.resolver' class='org.jbpm.jpdl.el.impl.JbpmVariableResolver' singleton='true' />"+
       "<bean name='jbpm.mail.address.resolver' class='org.jbpm.identity.mail.IdentityAddressResolver' singleton='true' />"+
      
       "<bean name='jbpm.job.executor' class='org.jbpm.job.executor.JobExecutor'>" +
       "<field name='jbpmConfiguration'><ref bean='jbpmConfiguration' /></field>"+
       "<field name='name'><string value='JbpmJobExector' /></field>"+
       "<field name='nbrOfThreads'><int value='1' /></field>"+
       "<field name='idleInterval'><int value='5000' /></field>"+
       "<field name='maxIdleInterval'><int value='3600000' /></field> <!-- 1 hour -->"+
       "<field name='historyMaxSize'><int value='20' /></field>"+
       "<field name='maxLockTime'><int value='600000' /></field> <!-- 10 minutes -->"+
       "<field name='lockMonitorInterval'><int value='60000' /></field> <!-- 1 minute -->"+
       "<field name='lockBufferTime'><int value='5000' /></field> <!-- 5 seconds -->"+
       "</bean>"+
       "</jbpm-configuration>"
       );
       org.jbpm.JbpmContext jbpmcontext =jbpmConfiguration.createJbpmContext();
      
       try {
      
       org.jbpm.graph.exe.ProcessInstance pi = jbpmcontext.newProcessInstance(processname);
      
       for (int i=0;i<attrnames.length;i++) pi.getContextInstance().setVariable(attrnames,attrvalues);
      
       pi.getRootToken().signal();
      
       jbpmcontext.save(pi);
       } catch (Exception ex) {
       ex.printStackTrace();
       } finally {
       // EXCEPTION HERE
       jbpmcontext.close();
       }
      
      
       }
      
      


      I get an exception when I am calling jbpmcontext.close():

      13:09:33,078 DEBUG [Services] executing default save operations
      13:09:33,078 DEBUG [HibernateSaveOperation] saving process instance
      13:09:33,093 DEBUG [SaveLogsOperation] flushing logs to logging service.
      13:09:33,109 DEBUG [CascadeSaveOperation] cascading save of 'org.jbpm.graph.exe.ProcessInstance@4d2262'
      13:09:33,109 DEBUG [JbpmContext] closing JbpmContext
      13:09:33,109 DEBUG [Services] closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@f9a36a
      13:09:33,109 DEBUG [DbPersistenceService] committing hibernate transaction
      13:09:33,140 ERROR [JDBCTransaction] JDBC commit failed
      java.sql.SQLException: You cannot commit during a managed transaction!
       at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:543)
       at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:334)
       at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:139)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:115)
       at org.jbpm.persistence.db.DbPersistenceService.endTransaction(DbPersistenceService.java:233)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:170)
       at org.jbpm.svc.Services.close(Services.java:222)
       at org.jbpm.JbpmContext.close(JbpmContext.java:139)
      [..]
      


      The task nodes in the process appears in the webapp, but when I use
      a transition button they won't follow the transition. Can anyone help me?