2 Replies Latest reply on Jul 31, 2008 9:50 AM by Sascha Janz

    LazyInitializationException on init ProcessInstance.instance

    Sascha Janz Master

      i got an LazyInitializationException when i try to get the current state of a processinstance.

      what is wrong?

      the code is

       GetProcessInstanceCommand cmd = new GetProcessInstanceCommand();
       returnValue = (ProcessInstance) executeCommand(cmd);
       System.out.println("Root token:" + returnValue.getRootToken().getName());
       System.out.println("process name:" + returnValue.getProcessDefinition().getName());
       System.out.println("process start:" + returnValue.getStart().toLocaleString());
       TaskInstance taskInstance = (TaskInstance)
       System.out.println("Task now is "+taskInstance.getName());

      the exception happens on returnValue.getTaskMgmtInstance()

        • 1. Re: LazyInitializationException on init ProcessInstance.inst
          Ronald van Kuijk Master

          that is because you get the processinstance object back without all data and not a handle to a processinstance in the engine (like in a hibernate session). You cannot perform actions on them like in the engine. You have to execute additional commands for this.

          • 2. Re: LazyInitializationException on init ProcessInstance.inst
            Sascha Janz Master

            ah ok...at last....there is some light ;-)))

            after writing my own command for what i want everything is ok

            code is

             public Object execute(JbpmContext jbpmContext) throws Exception {
             // TODO Auto-generated method stub
             List returnObject=null;
             ProcessInstance pi = jbpmContext.getProcessInstance(processInstanceId);
             Token t = pi.getRootToken();
             if ( t != null ) {
             returnObject= t.getNode().getLeavingTransitions();
             System.out.println("LeavingTransitions= " + returnObject.size());
             Iterator it = returnObject.iterator();
             while ( it.hasNext()) {
             Transition ta = (Transition ) it.next();
             System.out.println("Transition " + ta.getName());
             else {
             System.out.println("noroot token!");
             return returnObject;