2 Replies Latest reply on Feb 19, 2013 6:52 PM by roxy1987

    Couldn't retrieve the node name for the process instance in JBPM 5.0.0

    bardelman

      Hi,

      i tried to get the node Instance Id's using this method :

       

       

      public Long getNodeInstanceId() {

                          if(getRfpi()!=null)

                          if(getRfpi().getNodeInstances().iterator().hasNext())

                                    nodeInstanceId =  getRfpi().getNodeInstances().iterator().next().getNodeId();

                          return nodeInstanceId;

       

                }

       

      WHERE getRfpi()  is defined by :

       

       

      public static RuleFlowProcessInstance getRfpi() {

                          if(processInstance!=null)                    

                                    rfpi =(RuleFlowProcessInstance)processInstance;

                          return rfpi;

                }

       

      this worked fine BUT when i tried to get the node name by almost the same way :

       

      public static String getNodename() {

                          if(getRfpi()!=null)

                                    if(getRfpi().getNodeInstances().iterator().hasNext())

                                    nodename= getRfpi().getNodeInstances().iterator().next().getNodeName();

                          return nodename;

                }

       

       

      i got a NullPointerException pointing to this method..

       

      Any Help please ?

        • 1. Re: Couldn't retrieve the node name for the process instance in JBPM 5.0.0
          bardelman

          the exception is :

          Caused by: java.lang.NullPointerException

                  at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:67

          )

                  at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getWorkflowProcess(WorkflowPr

          ocessInstanceImpl.java:180)

                  at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getNodeContainer(WorkflowProc

          essInstanceImpl.java:68)

                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.getNode(NodeInstanceImpl.java:100)

                  at org.jbpm.workflow.instance.node.WorkItemNodeInstance.getNodeName(WorkItemNodeInstance.jav

          a:273)

          • 2. Re: Couldn't retrieve the node name for the process instance in JBPM 5.0.0
            roxy1987

            I dont understand which node of the process you are looking for. You can probably use the following code :

             

             

             

            readKnowledgeBase(processName); // custom method  to read knowledge base
             process = kbase.getProcess(processDefId);
            
            try
            {
                 List<NodeInstanceLog> nodeInstanceLogList;
                 for (Node node : (Node[])((WorkflowProcessImpl) process).getNodes())
                 {
                      // You have the node object. DO whatever you want with it.
                 }
            }
            catch(Exception e)
            {
            CustomExceptionHandler.handleException(e);
            }