1 Reply Latest reply on Oct 3, 2012 4:57 AM by Grigory Kalabin

    Human Task Service transactions fail

    Grigory Kalabin Newbie

      Hi everybody!

       

      I'm using jBPM 5.3.0.Final and JBoss 7.1.1.

       

      I'm trying to run jbpm with human task service.

       

      When I start processes without human tasks everything works fine. But when I try to run process with human task I get the following exception (see full error log in attachments):


      Caused by: java.lang.NullPointerException
              at org.drools.persistence.jta.JtaTransactionManager.getStatus(JtaTransactionManager.java:205) [drools-persistence-jpa-5.4.0.Final.jar:5.4.0.Final]
              at org.jbpm.task.service.persistence.TaskJTATransactionManager.getStatus(TaskJTATransactionManager.java:63) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
              at org.jbpm.task.service.persistence.TaskJTATransactionManager.begin(TaskJTATransactionManager.java:36) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
              at org.jbpm.task.service.persistence.TaskPersistenceManager.beginTransaction(TaskPersistenceManager.java:79) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
              at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:976) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
              ... 28 more
      

       

       

      I init HumanTaskService and jBPM in following way:

       

      Environment JBPM_ENVIRONMENT = KnowledgeBaseFactory.newEnvironment();
      JBPM_ENVIRONMENT.set(EnvironmentName.ENTITY_MANAGER_FACTORY, Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"));
      JBPM_ENVIRONMENT.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager());
      JBPM_ENVIRONMENT.set(EnvironmentName.GLOBALS, new MapGlobalResolver());
      
      Properties properties = new Properties();
      properties.put("drools.processInstanceManagerFactory", "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");
      properties.put("drools.processSignalManagerFactory", "org.jbpm.persistence.processinstance.JPASignalManagerFactory");
      KnowledgeSessionConfiguration JBPM_CONFIG = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);
      
      EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");
      TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
      
      MinaTaskServer taskServer = new MinaTaskServer(taskService);
      // start the server
      Thread thread = new Thread(taskServer);
      thread.start();
      
      TaskClient taskClient = new TaskClient(new MinaTaskClientConnector("myHtsClient",
                      new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
      if (!taskClient.connect(TASK_CLIENT_SERVER_ADDRESS, TASK_CLIENT_SERVER_PORT)) {
           logger.error("Could not connect task client");
      }
      
      StatefulKnowledgeSession session = JPAKnowledgeService.newStatefulKnowledgeSession(readKnowledgeBase(), JBPM_CONFIG, JBPM_ENVIRONMENT);
      session.getWorkItemManager().registerWorkItemHandler("Human Task", new MinaHTWorkItemHandler(session));
      

       

      And my persistence.xml:

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="2.0"
                   xmlns="http://java.sun.com/xml/ns/persistence"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      
          <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>
      
              <class>org.drools.persistence.info.SessionInfo</class>
              <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
              <class>org.drools.persistence.info.WorkItemInfo</class>
          </persistence-unit>
      
      
          <persistence-unit name="org.jbpm.task">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
              <jta-data-source>java:jboss/datasources/jbpmDS</jta-data-source>
              <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>
          </persistence-unit>
      </persistence>
      

       

       

      Also I'm using custom TransactionManagerLookup class (it's specifyed in hibernate.properties):

       

      public class TransactionManagerLookup extends JNDITransactionManagerLookup {
          @Override
          protected String getName() {
              return "java:jboss/TransactionManager";
          }
      
      
          @Override
          public String getUserTransactionName() {
              return "java:comp/UserTransaction";
          }
      }
      

       

       

      I even tried to rebind UserTransaction (which Task service looks up) to BitronixTransactionManager, but it not helps. I checked that there is UserTransaction object which TaskService looks up.

       

      Thank you for your attention. Have a good day!

        • 1. Re: Human Task Service transactions fail
          Grigory Kalabin Newbie

          I had an experiment: before a process start and after it I looked up the UserTransaction:


                  try {
                      logger.info("found: " + new InitialContext().lookup("java:comp/UserTransaction"));
                  } catch (NamingException e) {
                      logger.info("not found", e);
                  }
                  // start process code
          
                  try {
                      logger.info("found: " + new InitialContext().lookup("java:comp/UserTransaction"));
                  } catch (NamingException ex) {
                      logger.info("not found", ex);
                  }
          
          

           

           

          The name java:comp/UserTransaction I took from org.drools.persistence.jta.JtaTransactionManager which falls with NPE.

           

          It still falls and in my log:

           

          30974Thu Jan 01 12:39:35 MSK 1970INFOfound: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@1033fb5com.example.my.jbpm.rest.ProcessManagementResourceshttp--127.0.0.1-8080-2
          Note [note=]
          31052Thu Jan 01 12:39:36 MSK 1970FINENo UserTransaction found at JNDI location [java:comp/UserTransaction]org.drools.persistence.jta.JtaTransactionManagerNioProcessor-2
          Note [note=]
          31159Thu Jan 01 12:39:37 MSK 1970INFOfound: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@1033fb5com.example.my.jbpm.rest.ProcessManagementResourceshttp--127.0.0.1-8080-2
          Note [note=]