0 Replies Latest reply on Jan 3, 2014 11:46 AM by bule java

    jbpm5.4 register LocalHTWorkItemHandler,transaction error!!

    bule java Newbie

      my code  below,i  wouldn`t to use hunman task server, so i register LocalHTWorkItemHandler,but not success。Beside,


      what the benefit if  deloy the human task  server alone.

       

      if("Local".equalsIgnoreCase(starge)){
              EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");
             org.jbpm.task.service.TaskService taskService = new org.jbpm.task.service.TaskService(
             emf, SystemEventListenerFactory.getSystemEventListener()); 
             LocalTaskService localService=new LocalTaskService(taskService);
             LocalHTWorkItemHandler workItemHandler=  new LocalHTWorkItemHandler(localService, ksession,OnErrorAction.RETHROW);
             workItemHandler.connect();
             workItemHandler.setLocal(true);
             ksession.getWorkItemManager().registerWorkItemHandler("Human Task",workItemHandler); 
      
      
        UserGroupCallbackManager manager = UserGroupCallbackManager.getInstance();
        if (!manager.existsCallback()) {
             UserGroupCallback userGroupCallback = getInstance("org.jbpm.task.identity.DefaultUserGroupCallbackImpl");
        manager.setCallback(userGroupCallback);
        }
             System.out.println("Task service startup completed successfully !");
      //mina,HornetQ 
       }else{
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", 
        new org.jbpm.process.workitem.wsht.AsyncHornetQHTWorkItemHandler("jbpmConsoleHTHandler", 
                       TaskClientFactory.newAsyncInstance(starge,"taskClient",false) , ksession, org.jbpm.task.utils.OnErrorAction.LOG));
                   
      
         }
      

       

      when start process by the  "Local"  condition  throw below exception,but the "else" condition  is OK

       

      00:12:36,915 WARN  [org.jbpm.task.service.persistence.TaskLocalTransactionManager] (http--127.0.0.1-8080-1) Unable to commit transaction: javax.persistence.RollbackException: Error while committing the transaction
        at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:90) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
        at org.jbpm.task.service.persistence.TaskLocalTransactionManager.commit(TaskLocalTransactionManager.java:55) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.task.service.persistence.TaskPersistenceManager.endTransaction(TaskPersistenceManager.java:107) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:1118) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.task.service.TaskServiceSession.addTask(TaskServiceSession.java:189) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.task.service.local.LocalTaskService.addTask(LocalTaskService.java:70) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.process.workitem.wsht.GenericHTWorkItemHandler.executeWorkItem(GenericHTWorkItemHandler.java:182) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]
        at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalExecuteWorkItem(JPAWorkItemManager.java:55) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]
        at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:107) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:126) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:279) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:238) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:126) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:194) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:309) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:170) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:140) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
        at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1098) [drools-core-5.5.0.Final.jar:5.5.0.Final]
        at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:320) [drools-core-5.5.0.Final.jar:5.5.0.Final]
        at org.drools.command.runtime.process.StartProcessCommand.execute(StartProcessCommand.java:120) [drools-core-5.5.0.Final.jar:5.5.0.Final]
        at org.drools.command.runtime.process.StartProcessCommand.execute(StartProcessCommand.java:39) [drools-core-5.5.0.Final.jar:5.5.0.Final]
        at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36) [drools-core-5.5.0.Final.jar:5.5.0.Final]
        at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:373) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]
        at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:223) [drools-core-5.5.0.Final.jar:5.5.0.Final]
      

       

      Caused by: javax.persistence.PersistenceException: org.hibernate.TransactionException: commit failed
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1361) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:78) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
        ... 46 more
      Caused by: org.hibernate.TransactionException: commit failed
        at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:185) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:73) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
        ... 46 more
      Caused by: org.hibernate.TransactionException: unable to commit against JDBC connection
        at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:116) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:178) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        ... 47 more
      Caused by: java.sql.SQLException: You cannot commit during a managed transaction!
        at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:981)
        at org.jboss.jca.adapters.jdbc.WrappedConnection.commit(WrappedConnection.java:757)
        at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:112) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        ... 48 more
      

       

      persistence.xml

       

        <persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <jta-data-source>java:jboss/datasources/jbpmDS</jta-data-source>
          <mapping-file>META-INF/JBPMorm-JPA2.xml</mapping-file>
          <mapping-file>META-INF/ProcessInstanceInfoMapping-JPA2.xml</mapping-file>
          <mapping-file>META-INF/ExtraIndexes.hbm.xml</mapping-file>
      
      
          <class>org.drools.persistence.info.SessionInfo</class>
          <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</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.MySQLDialect" />
            <property name="hibernate.max_fetch_depth" value="3" />
            <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.JBossTransactionManagerLookup" />
            <property name="hibernate.id.new_generator_mappings" value="false" />
          </properties>
        </persistence-unit>
        
        
        <persistence-unit name="org.jbpm.task" transaction-type="RESOURCE_LOCAL">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <non-jta-data-source>java:jboss/datasources/jbpmDS</non-jta-data-source>       
          <mapping-file>META-INF/Taskorm-JPA2.xml</mapping-file>
          
          <class>org.jbpm.task.Attachment</class>
          <class>org.jbpm.task.BooleanExpression</class>
          <class>org.jbpm.task.Comment</class>
          <class>org.jbpm.task.Content</class>
          <class>org.jbpm.task.Deadline</class>
          <class>org.jbpm.task.Delegation</class>
          <class>org.jbpm.task.EmailNotification</class>
          <class>org.jbpm.task.EmailNotificationHeader</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.OnAllSubTasksEndParentEndStrategy</class>
          <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>
          <class>org.jbpm.task.PeopleAssignments</class>
          <class>org.jbpm.task.Reassignment</class>
          <class>org.jbpm.task.Status</class>
          <class>org.jbpm.task.SubTasksStrategy</class>
          <class>org.jbpm.task.Task</class>
          <class>org.jbpm.task.TaskData</class>
          <class>org.jbpm.task.User</class>
          <properties>
            <!-- <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>  -->   
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>       
            <property name="hibernate.max_fetch_depth" value="3"/>
            <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.JBossTransactionManagerLookup" />
            
            <!-- BZ 841786: AS7/EAP 6/Hib 4 uses new (sequence) generators which seem to cause problems -->      
            <property name="hibernate.id.new_generator_mappings" value="false" />
          </properties>
        </persistence-unit>