3 Replies Latest reply on Aug 13, 2014 12:52 AM by Yan Naing Kyaw

    Iusse of human task persistence - Transaction not active

    Adam Peng Newbie

      Hi all,

       

              I encoutnered issue when I was executing process including Human Tasks (on the other hand without human task the persistence was working fine!)

       

              The error message is as below:

               

      Hibernate: insert into ProcessInstanceInfo (OPTLOCK, processId, startDate, lastReadDate, lastModificationDate, state, processInstanceByteArray) values (?, ?, ?, ?, ?, ?, ?)
      Hibernate: insert into WorkItemInfo (creationDate, name, processInstanceId, state, OPTLOCK, workItemByteArray) values (?, ?, ?, ?, ?, ?)
      Hibernate: insert into Task (archived, allowedToDelegate, taskInitiator_id, priority, activationTime, actualOwner_id, createdBy_id, createdOn, documentAccessType, documentContentId, documentType, expirationTime, faultAccessType, faultContentId, faultName, faultType, outputAccessType, outputContentId, outputType, parentId, previousStatus, processId, processInstanceId, processSessionId, skipable, status, workItemId, OPTLOCK) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      Hibernate: insert into I18NText (language, text) values (?, ?)
      Hibernate: insert into I18NText (language, text) values (?, ?)
      Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=? and OPTLOCK=?
      Hibernate: insert into Content (content) values (?)
      Hibernate: update ProcessInstanceInfo set OPTLOCK=?, processId=?, startDate=?, lastReadDate=?, lastModificationDate=?, state=?, processInstanceByteArray=? where InstanceId=? and OPTLOCK=?
      Hibernate: update Task set archived=?, allowedToDelegate=?, taskInitiator_id=?, priority=?, activationTime=?, actualOwner_id=?, createdBy_id=?, createdOn=?, documentAccessType=?, documentContentId=?, documentType=?, expirationTime=?, faultAccessType=?, faultContentId=?, faultName=?, faultType=?, outputAccessType=?, outputContentId=?, outputType=?, parentId=?, previousStatus=?, processId=?, processInstanceId=?, processSessionId=?, skipable=?, status=?, workItemId=?, OPTLOCK=? where id=? and OPTLOCK=?
      Hibernate: update I18NText set Task_Descriptions_Id=? where id=?
      Hibernate: insert into PeopleAssignments_BAs (task_id, entity_id) values (?, ?)
      Hibernate: update WorkItemInfo set creationDate=?, name=?, processInstanceId=?, state=?, OPTLOCK=?, workItemByteArray=? where workItemId=? and OPTLOCK=?
      Hibernate: insert into PeopleAssignments_PotOwners (task_id, entity_id) values (?, ?)
      java.lang.RuntimeException: Could not commit transaction
       at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:994)
       at org.jbpm.task.service.TaskServiceSession.addTask(TaskServiceSession.java:186)
       at org.jbpm.task.service.TaskServerHandler.messageReceived(TaskServerHandler.java:144)
       at org.jbpm.task.service.mina.MinaTaskServerHandler.messageReceived(MinaTaskServerHandler.java:41)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:716)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
       at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:427)
       at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:245)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
       at org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:177)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
       at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)
       at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:715)
       at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:668)
       at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:657)
       at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:68)
       at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1141)
       at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
       at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.RuntimeException: Unable to rollback transaction
       at org.jbpm.task.service.persistence.TaskLocalTransactionManager.rollback(TaskLocalTransactionManager.java:77)
       at org.jbpm.task.service.persistence.TaskPersistenceManager.endTransaction(TaskPersistenceManager.java:89)
       at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:982)
       ... 28 more
      Caused by: java.lang.IllegalStateException: Transaction not active
       at org.hibernate.ejb.TransactionImpl.rollback(TransactionImpl.java:104)
       at org.jbpm.task.service.persistence.TaskLocalTransactionManager.rollback(TaskLocalTransactionManager.java:70)
       ... 30 more
      
      

       

      Start task server

       

      :

       

        EntityManagerFactory emf = (EntityManagerFactory) applicationContext.getBean("emf");
      //  EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa.task.local");
        TaskService taskService = new TaskService(emf,SystemEventListenerFactory.getSystemEventListener());
        TaskServiceSession taskSession = taskService.createSession();
        taskSession.addUser(new User("Administrator"));
        MinaTaskServer server = new MinaTaskServer(taskService);
        Thread thread = new Thread(server);
        thread.start();
        log.info("Mina Server has started.");
        taskSession.dispose();

       

      p

       

      ersistence.xml

       

      <persistence-unit name="org.jbpm.persistence.jpa.local" transaction-type="RESOURCE_LOCAL">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          
          <mapping-file>META-INF/JBPMorm.xml</mapping-file>
          <mapping-file>META-INF/ProcessInstanceInfo.hbm.xml</mapping-file>
       <mapping-file>META-INF/Taskorm.xml</mapping-file>
       
        <class>org.jbpm.task.Attachment</class>
        <class>org.jbpm.task.Content</class>
        <class>org.jbpm.task.BooleanExpression</class>
        <class>org.jbpm.task.Comment</class>
        <class>org.jbpm.task.Deadline</class>
        <class>org.jbpm.task.Comment</class>
        <class>org.jbpm.task.Deadline</class>
        <class>org.jbpm.task.Delegation</class>
        <class>org.jbpm.task.Escalation</class>
        <class>org.jbpm.task.Group</class>
        <class>org.jbpm.task.I18NText</class>
        <class>org.jbpm.task.Notification</class>
        <class>org.jbpm.task.EmailNotification</class>
        <class>org.jbpm.task.EmailNotificationHeader</class>
        <class>org.jbpm.task.PeopleAssignments</class>
        <class>org.jbpm.task.Reassignment</class>
        <class>org.jbpm.task.Status</class>
        <class>org.jbpm.task.Task</class>
        <class>org.jbpm.task.TaskData</class>
        <class>org.jbpm.task.SubTasksStrategy</class>
        <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>
        <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>
        <class>org.jbpm.task.User</class>
          <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
          <class>org.drools.persistence.info.SessionInfo</class>
          <class>org.drools.persistence.info.WorkItemInfo</class>
          <class>org.jbpm.process.audit.ProcessInstanceLog</class>
          <class>org.jbpm.process.audit.NodeInstanceLog</class>
          <class>org.jbpm.process.audit.VariableInstanceLog</class>
          <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
            <property name="hibernate.connection.autocommit" value="false" />
            <property name="hibernate.max_fetch_depth" value="3"/>
            <property name="hibernate.archive.autodetection" value="false"/>
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.show_sql" value="true" />
              <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />
          </properties>        
        </persistence-unit>
      
      

       

       

      applicationContext-jbpm.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:drools="http://drools.org/schema/drools-spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring-1.3.0.xsd">
      
       <bean id="jbpmDS" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
        <property name="url" value="${productDB.jbpm.url}"/>
        <property name="username" value="${productDB.username}"/>
        <property name="password" value="${productDB.password}"/>
       </bean>
       <bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="jbpmDS" />
        <property name="persistenceUnitName" value="org.jbpm.persistence.jpa.local" />
       </bean>
       
       
       <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="emf" />
       </bean>
       
       
       <drools:grid-node id="node1" />
       <drools:kbase id="kbase1" node="node1">
        <drools:resources>
         <drools:resource type="BPMN2" source="classpath:processes/test.bpmn" />
         </drools:resources>
       </drools:kbase>
       <drools:ksession id="ksession1" type="stateful" kbase="kbase1" node="node1">
        <drools:configuration>
         <drools:jpa-persistence>
          <drools:transaction-manager ref="txManager" />
          <drools:entity-manager-factory ref="emf" />
         </drools:jpa-persistence>
        </drools:configuration>
       </drools:ksession>
       
       <bean id="testService" class="testServiceImpl">
        <property name="ksession" ref="ksession1" />
        <property name="processId" value="test" />
       </bean>
       
       
      </beans>
      
      

       

       

      And then when I use ksession1 to startProcess, I got above error message. And it's ok to start a process without human task.

       

      Any hints/suggestion would be appreciated !!

       

      BTW I'm using jBPM 5.3.