6 Replies Latest reply on Aug 12, 2005 2:58 AM by camunda

    ProcessInstance in Token is null?

    camunda

      Hi I want to get variables from a token (or something else, doesn't matter), but

      Token token = session.getGraphSession().loadToken(tokenId);
      token.getProcessInstance() is null, so I can't get informations about the processInstance of the token.

      What's wrong here?

        • 1. Re: ProcessInstance in Token is null?
          aguizar

          I'm having trouble reproducing your problem. Can you provide a code snippet which shows what you are trying to do?

          The only reason I can imagine right now for the null process instance is that you had originally created the token with the default constructor, which does not set any field.

          • 2. Re: ProcessInstance in Token is null?
            camunda

            OK, I have found the problem and my mistake:

            1.) I start a new process with a transition
            2.) In this first transition a decision occurs
            3.) The decision want to get a variable from the process, but doe not use the executionContext but a own class, which retrieves the token from the database (but the new process instance is not comitted yet).

            That causes the problem!

            No we work with the executionContext in the Decision and everything works fine!

            Thanks for your effort!

            • 3. Re: ProcessInstance in Token is null?
              camunda

              OK, we still have a problem:

              With session.getGraphSession().loadToken(tokenId) the processInstance in the token is always null! This is the root token of a process instance.

              Even with session.getGraphSession().loadProcessInstance(tokenId).getRootToken()
              the processInstance in this token is null!

              Our process is started with:

              ProcessInstance pi = session.getGraphSession().findLatestProcessDefinition(processName).createProcessInstance();
              pi.getContextInstance().addVariables(params);
              pi.getRootToken().signal(transitionName);
              return pi.getRootToken().getId();

              Any hints to that?

              • 4. Re: ProcessInstance in Token is null?
                camunda

                OK, solved!

                We also have to close the jBpmSession after every commit to work properly...

                Strange, but I don't know hibernate so good (we use JDO ;-)), I think it makes sense in some way...

                • 5. Re: ProcessInstance in Token is null?
                  aguizar

                  I see a connection between your problems and Daniel's problem with stale data in variable instances.
                  http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889539#3889539
                  So, the only way things work properly for you is using the session for a single transaction? If you start a new transaction and load a token, its process instace is null?

                  • 6. Re: ProcessInstance in Token is null?
                    camunda

                    Yepp, right.