1 Reply Latest reply on Aug 22, 2005 6:24 PM by fallow

    Update Context and end Task

    fallow

      I am working to create a method that updates the variables for a process instance ends a task. However I keep getting the message "Found shared references to a collection". I am using the following logic pulled out of the documentation.

      JBPMSession jS = jbpmSessionFactory.openJbpmSession();
      try{

      jS.beginTransaction();

      TaskMgmtSession tS = jbpmSession.getTaskMgmtSession();
      TaskInstance ti = tS.loadTaskInstance(taskId);

      Token t = ti.getToken();
      ProcessInstance pi = t.getProcessInstance();

      ContextInstance ci = pi.getContextInstance();
      ci.addVariables(<map of vars>);

      ti.end();

      jS.getGraphSession().saveProcessInstance(pi);

      jS.commitTransaction();
      jS.close();

      } catch(Exception e){

      jS.rollbackTransaction();
      jS.close();
      }

      My error occurs in the commitTransaction. Am I properly loading up the objects? Can I do multiple changes to the objects within the same transaction (both the Task.end and the variables updates).

      Thanks,

      Fallow

        • 1. Re: Update Context and end Task
          fallow

          Looking at the docs and your test code I am unclear as to whether or not I should be doing the call to jS.getGraphSession().saveProcessInstance(pid) when the process already exists.

          Is saveProcessInstance used whenever I want to commit changes to a process to the DB? Is this true for both Tasks and Variables within the context? Or will the commit on the transaction actually sync up the DB with the objects changed attributes.

          Thanks,

          Fallow