3 Replies Latest reply on Oct 6, 2009 5:46 AM by kukeltje

    jbpm 4.1 - execution not waiting for Task Form inputs

      Hi,
      Simple process definition( with a taskform ) when run using jbPM APIS is not getting stopped at task form node but it completes its execution.
      I am trying to test the process using jBPM APIs not console.
      Code attached below for reference.

      Process should wait for user inputs through a form which is attached to "review" task. I also tried removing line " taskService.completeTask(task.getId());"
      from jbpm test case but no sucsess.

      Can anybody guide me in this regard ?

      Process definition :


      <?xml version="1.0" encoding="UTF-8"?>
      
      <process name="FormDynamic" xmlns="http://jbpm.org/4.0/jpdl">
      
       <start g="20,20,48,48">
       <transition to="review"/>
       </start>
      
       <task assignee="peter" form="org/jbpm/examples/formdynamic/givedetails.ftl" g="96,16,127,52" name="review">
       <transition to="wait"/>
       </task>
       <state g="268,24,96,31" name="wait"/>
      
      </process>
      


      jbpm test case :

      package org.jbpm.examples.formdynamic;
      
      import java.util.HashMap;
      import java.util.List;
      import java.util.Map;
      
      import org.jbpm.api.ProcessInstance;
      import org.jbpm.api.task.Task;
      import org.jbpm.test.JbpmTestCase;
      
      public class FormDynamicTest extends JbpmTestCase {
       String deploymentId;
      
       protected void setUp() throws Exception {
       super.setUp();
      
       deploymentId = repositoryService.createDeployment()
       .addResourceFromClasspath("org/jbpm/examples/formdynamic/FormDynamic.jpdl.xml")
       .deploy();
       }
      
       protected void tearDown() throws Exception {
       repositoryService.deleteDeploymentCascade(deploymentId);
      
       super.tearDown();
       }
      
       public void testTaskAssignee() {
       Map<String, Object> variables = new HashMap<String, Object>();
       variables.put("order", "johndoe");
       ProcessInstance processInstance = executionService.startProcessInstanceByKey("FormDynamic", variables);
       String pid = processInstance.getId();
       //ProcessInstance processInstance = executionService.startProcessInstanceByKey("FormDynamic");
       List<Task> taskList=taskService.findPersonalTasks("peter");
       Task task=taskList.get(0);
      
       taskService.completeTask(task.getId());
      
       System.out.println("List is"+taskList);
      
       // verify that process moved to the next state
       processInstance = executionService.findProcessInstanceById(pid);
       assertTrue(processInstance.isActive("wait"));
      
      
      
       }
      }
      


      jbpm test case result :

      14:31:37,940 FIN | [BaseJbpmTestCase] === starting testTaskAssignee =============================
      14:31:38,231 INF | [Environment] Hibernate 3.3.1.GA
      14:31:38,231 INF | [Environment] hibernate.properties not found
      14:31:38,231 INF | [Environment] Bytecode provider name : javassist
      14:31:38,231 INF | [Environment] using JDK 1.4 java.sql.Timestamp handling
      14:31:38,271 INF | [Configuration] configuring from resource: jbpm.hibernate.cfg.xml
      14:31:38,271 INF | [Configuration] Configuration resource: jbpm.hibernate.cfg.xml
      14:31:38,321 INF | [Configuration] Reading mappings from resource : jbpm.repository.hbm.xml
      14:31:38,441 INF | [Configuration] Reading mappings from resource : jbpm.execution.hbm.xml
      14:31:38,541 INF | [Configuration] Reading mappings from resource : jbpm.history.hbm.xml
      14:31:38,591 INF | [Configuration] Reading mappings from resource : jbpm.task.hbm.xml
      14:31:38,621 INF | [Configuration] Reading mappings from resource : jbpm.identity.hbm.xml
      14:31:38,631 INF | [Configuration] Configured SessionFactory: null
      14:31:38,651 INF | [DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
      14:31:38,651 INF | [DriverManagerConnectionProvider] Hibernate connection pool size: 20
      14:31:38,651 INF | [DriverManagerConnectionProvider] autocommit mode: false
      14:31:38,651 INF | [DriverManagerConnectionProvider] using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:mem:.
      14:31:38,651 INF | [DriverManagerConnectionProvider] connection properties: {user=sa, password=****}
      14:31:38,791 INF | [Dialect] Using dialect: org.hibernate.dialect.HSQLDialect
      14:31:38,791 INF | [TransactionFactoryFactory] Using default transaction strategy (direct JDBC transactions)
      14:31:38,801 INF | [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
      14:31:38,801 INF | [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
      14:31:38,831 INF | [SessionFactoryImpl] building session factory
      14:31:39,322 INF | [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
      14:31:39,332 INF | [SchemaExport] Running hbm2ddl schema export
      14:31:39,332 INF | [SchemaExport] exporting generated schema to database
      14:31:39,362 INF | [SchemaExport] schema export complete
      14:31:39,793 FIN | [ProcessDefinitionImpl] creating new execution for process 'FormDynamic'
      14:31:39,793 FIN | [DefaultIdGenerator] generated execution id FormDynamic.1
      14:31:39,813 FIN | [ScopeInstanceImpl] create variable 'order' in 'execution[FormDynamic.1]' with value 'johndoe'
      14:31:39,813 FIN | [ExecuteActivity] executing activity(17872448)
      14:31:39,813 FIN | [ExecuteActivity] executing activity(review)
      14:31:39,843 FIN | [TaskQueryImpl] select task from org.jbpm.pvm.internal.task.TaskImpl as task where task.assignee = :assignee order by task.priority desc
      14:31:39,853 FIN | [TaskQueryImpl] setting parameter assignee: peter
      14:31:39,863 FIN | [Signal] signalling activity(review), signalName=completed
      14:31:39,863 FIN | [ExecuteActivity] executing activity(wait)
      List is[Task(review)]
      14:31:39,903 FIN | [DbSessionImpl] deleting history process instance FormDynamic.1
      14:31:39,923 FIN | [DbSessionImpl] deleting process instance FormDynamic.1
      14:31:39,923 FIN | [DeleteDeploymentCmd] deleting deployment 1
      14:31:39,953 FIN | [BaseJbpmTestCase] === ending testTaskAssignee =============================
      
      


        • 1. Re: jbpm 4.1 - execution not waiting for Task Form inputs
          tcr

          Hi makarandk502,

          if I remove the
          taskService.completeTask(task.getId());

          and change the assert to check for "review" instead of "wait" the tests works for me. I only had a 4.0 to hand, not 4.1 but I think this should work in 4.1....


          .......
           Task task=taskList.get(0);
          
           //taskService.completeTask(task.getId());
          
           System.out.println("List is"+taskList);
          
           //verify that process moved to the next state
           processInstance = executionService.findProcessInstanceById(pid);
           assertTrue(processInstance.isActive("review"));
          


          regards!

          • 2. Re: jbpm 4.1 - execution not waiting for Task Form inputs

            Hi,

            Even in my case, its reaching at "review" task. print statements like "List is[Task(review)]" But in "review" task, we have associated a form which can be viewed in jbpm console. Ideally we should view the form and once we enter "submit" , it should proceed further. Basically it is not waiting for user inputs in taskform

            But I am not able to see the form in jbpm console and it is deleting process instance. I am attaching jbpm test case result below.


            11:00:00,036 FIN | [TaskQueryImpl] select task from org.jbpm.pvm.internal.task.TaskImpl as task where task.assignee = :assignee order by task.priority desc
            11:00:00,036 FIN | [TaskQueryImpl] setting parameter assignee: peter
            11:00:00,066 FIN | [DbSessionImpl] deleting history process instance FormDynamic.1
            11:00:00,087 FIN | [DbSessionImpl] deleting process instance FormDynamic.1
            11:00:00,097 FIN | [DeleteDeploymentCmd] deleting deployment 1
            11:00:00,127 FIN | [BaseJbpmTestCase] === ending testTaskAssignee =============================
            
            


            • 3. Re: jbpm 4.1 - execution not waiting for Task Form inputs
              kukeltje

              Correct, since your unittest ends (how can the test know it has to wait for something..... If you e.g. build in a Thread.sleep(1000) loop endlessly and check in the loop if the task has ended (do a break then) it could work. That is *not* the way unittests are *normally* used though. The user is also 'simulated' in the unittest.