7 Replies Latest reply on May 17, 2007 5:48 PM by lachelt

    How to get Node name for a TaskInstance?

    lachelt

      I have a TaskInstance, which I got by invoking

      taskInstance = JbpmContext.getTaskInstance( instanceId )

      Now I'd like to get the name of the node that this taskInstance is from.
      So I figured this would do the trick:

      taskInstance.getTask().getTaskNode().getName()

      But I get a NullPointerException because the Task doesn't seem to be properly initialized... it has a null taskNode member (and many other null members).

      Is this a defect? Or more likely I'm just not understanding something fundamental about jBPM (I am a noob).

      Would someone please enlighten me?

      Thanks,
      -Jon

        • 1. Re: How to get Node name for a TaskInstance?
          kukeltje

          I would have tried doing it the same way. Can you check in the database if it is correctly stored? In the meantime I'll look at the testcases if there is one for this situation with and without db.

          • 2. Re: How to get Node name for a TaskInstance?
            lachelt


            Oh... could this be because this task is in my start-state?

            If that is the case, then how can I tell that, and find out which "node" in the process the task is for? I see that the Task has a member "startState" which is also null at this time... so that doesn't really help me.


            To answer the question from Ronald, i'm using hypersonic DB. So I don't know how to check that. Is there a JDBC driver I can use to talk to that DB (say from eclipse)?

            Thanks,
            -Jon

            • 3. Re: How to get Node name for a TaskInstance?
              kukeltje

              AFAIK, This could happen if the context has not been saved yet, but I'm not sure.

              Regarding the HSQLDB, if it is running in jboss, see the end of http://wiki.jboss.org/wiki/Wiki.jsp?page=JbpmGettingStarted

              • 4. Re: How to get Node name for a TaskInstance?
                lachelt

                sorry about my stupid question about the jdbc driver. i just found it.

                • 5. Re: How to get Node name for a TaskInstance?
                  kukeltje

                  :-)

                  Still then... if it runs in jbpm and has no tcp configured, you will not be able to access it from eclipse, dbvisualizer or whatever if the appserver is running.

                  • 6. Re: How to get Node name for a TaskInstance?
                    lachelt

                    Here is the code I used to start the process instance:

                    ProcessInstance instanceForUpdate = jbpmContext.newProcessInstanceForUpdate(processDefinition.getName());
                    instanceForUpdate.getTaskMgmtInstance().createStartTaskInstance();
                    jbpmContext.save(instanceForUpdate);
                    jbpmContext.close();
                    


                    (I just added the save(), which I didn't think I needed in this case... and it didn't help).

                    Then at some later time (with a new jbpmContext), I've gotten the task instance as I noted in the initial post.

                    Does that help? The way I'm starting the workflow seemed a little odd, but seems to work. Was there some other way I'm supposed to do it?

                    Thanks,
                    -Jon

                    • 7. Re: How to get Node name for a TaskInstance?
                      lachelt

                      OK. I've confirmed that the TaskInstance is getting persisted. In the DB I can see the Task Instance and it has the proper key in the TASK_ column. The JBPM_TASK table has an entry with a matching ID_.

                      So I do this in my code:

                      TaskInstance taskInstance = jbpmContext.loadTaskInstance(instanceId);
                      Task task = taskInstance.getTask();
                      TaskNode node = task.getTaskNode();
                      


                      The Task object gets loaded properly, but the TaskNode always comes back null.

                      Any ideas?