3 Replies Latest reply on Oct 17, 2014 2:19 PM by Darren Osten

    How to get the nodeType of a node/nodeInstance?

    James Yu Newbie

      Hi all,

       

      My question is: How can I get the nodeType of a node/nodeInstance?

       

      I am trying to wrap the startProcess and signalEvent into new methods (say newStartProcess and signalProcess) so I don't need to explicitly call registerWorkItemHandler.

      What I have in mind is:

      1. when start a process, the wrapping method (newStartProcess) will find out all WorkItem nodes and call registerWorkItemHandler for each of the WorkItem nodes.

      2. when signal an event, the wrapping method (signalProcess) will find out the remaining WorkItem nodes to be done and call registerWorkItemHandler for each of them.

       

      In "nodeinstancelog" table, there is a "nodeType" column that helps to identify the WorkItem nodes.

      However, I am unable to find "getNodeType" method in "NodeInstance" or "Node" class.

      So, how do I get the nodeType of a node/nodeInstance?

        • 1. Re: How to get the nodeType of a node/nodeInstance?
          Darren Osten Newbie

          You might have to check the class type of the node.  There are several implementations of node class (like org.jbpm.workflow.instance.node.HumanTaskNodeInstance).

          • 2. Re: How to get the nodeType of a node/nodeInstance?
            James Yu Newbie

            Hi Darren,

             

            Do you have any idea for the following exception ?

            Process instance 1[xxxxxxxxxx] is disconnected.

             

            I tried to get the node instance with the following code:

                    RuntimeEngine engine = manager.getRuntimeEngine(null);

                    KieSession ksession = engine.getKieSession();

                    ProcessInstance processInstance = ksession.getProcessInstance(lpid);

                    WorkflowProcessInstance wfInstance = ((WorkflowProcessInstance)processInstance);

             

                    String nodeName = "";

                    if(processInstance != null) {

                        NodeInstance ni = wfInstance.getNodeInstances().iterator().next();

                        System.out.println(ni.getClass().getName());

                        nodeName = ni.getNodeName();

                    }

             

            but I get this exception:

            java.lang.RuntimeException: Process instance 1[xxxxxxxxxx] is disconnected.

            org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:90)

            org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getWorkflowProcess(WorkflowProcessInstanceImpl.java:212)

            org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getNodeContainer(WorkflowProcessInstanceImpl.java:81)

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

            org.jbpm.workflow.instance.impl.NodeInstanceImpl.getNodeName(NodeInstanceImpl.java:88)

            com.fet.poc.npp.bpm.NppDemoProcessService.getNodeByTxid(NppDemoProcessService.java:116)

            com.fet.poc.npp.restful.POCService.getNodeByTxid(POCService.java:135)

            sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

            sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

            sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

            java.lang.reflect.Method.invoke(Method.java:606)

            org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)

            org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)

            org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:165)

            org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:92)

            org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)

            java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)

            java.util.concurrent.FutureTask.run(FutureTask.java:262)

            org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)

            org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)

            org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)

            org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)

            org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)

            org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)

            org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:152)

            org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)

            org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)

            org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:113)

            javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

            org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)

            • 3. Re: How to get the nodeType of a node/nodeInstance?
              Darren Osten Newbie

              I never seen that error before.  Maybe the instance is no longer active.