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

    LazyInitializationException on init ProcessInstance.instance

    ajanz

      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();
       cmd.setProcessInstanceId(process_instance_id);
       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)
       returnValue.getTaskMgmtInstance().getTaskInstances().iterator().next();
      
      
       System.out.println("Task now is "+taskInstance.getName());
      



      the exception happens on returnValue.getTaskMgmtInstance()

        • 1. Re: LazyInitializationException on init ProcessInstance.inst
          kukeltje

          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
            ajanz

            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;
             }
            }