4 Replies Latest reply on Sep 16, 2010 7:04 AM by James Baker

    TaskQuery.processInstanceId bug?

    Jimmy Smith Newbie

      I can't get taskQuery.processInstanceId(xxx) working, always returns empty result, even if I hardcode my code with the value matching the procinst_ field of the task in the database.


      Is this a (known) bug?

       

      using jBPM 4.4

        • 1. Re: TaskQuery.processInstanceId bug?
          Michael Wohlfart Expert

          there is a testcase for this: org.jbpm.test.task.TaskQueryProcessTest, so I tend to assume there is no bug, but of course you never know, can you provide a testcase?

          • 2. Re: TaskQuery.processInstanceId bug?
            Jimmy Smith Newbie

            This is the best I can do. Of any use?

             

            String processInstanceId = (set somewhere) => Tomcat in debug mode shows it has value 7


            TaskService taskService = processEngine.getTaskService();
            Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).uniqueResult();
            taskService.completeTask(task.getId());

             

            I get a NullPointerException, because task is null. Looking in the database, its procinst_ field is set to 7.

            (I use the uniqueResult because there can only be one task at this stage for the process instance)


            org.jbpm.test.task.TaskQueryProcessTest is not in my distribution of 4.4, btw. There are only 5 packages under org.jbpm.test, task is not one of them.

            • 3. Re: TaskQuery.processInstanceId bug?
              Michael Wohlfart Expert

              the full path is

              /jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryProcessTest.java

              it was added in Revision 5032 at June 12th 2009, so it should be in 4.4

              • 4. Re: TaskQuery.processInstanceId bug?
                James Baker Newbie

                If you set the following parameters in your jbpm.hibernate.cfg.xml

                 

                {code:xml}

                     <property name="hibernate.format_sql">true</property>

                     <property name="hibernate.show_sql">true</property>

                     <property name="hibernate.use_sql_comments">true</property>

                {code}

                 

                then you can see the query being generated by jBPM and work out why your task isn't being loaded by running it directly on the database.

                I had a similar problem and it turned out that it was because my task had never been persisted.

                (spring configuration mistake on my part).