Discussion:
[jboss-user] [jBPM] - Couldn't retrieve the node name for the process instance in JBPM 5.4
neeraj sharma
2013-01-10 05:40:14 UTC
Permalink
neeraj sharma [https://community.jboss.org/people/nsharm28] created the discussion

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

To view the discussion, visit: https://community.jboss.org/message/789988#789988

--------------------------------------------------------------
Hi,

When i am trying  to retreive the node name for particular process instance. I am getting following Error.

        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.lang.NullPointerException
        at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:68)
        at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getWorkflowProcess(WorkflowProcessInstanceImpl.java:181)
        at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getNodeContainer(WorkflowProcessInstanceImpl.java:69)
        at org.jbpm.workflow.instance.impl.NodeInstanceImpl.getNode(NodeInstanceImpl.java:103)
        at org.jbpm.workflow.instance.impl.NodeInstanceImpl.getNodeName(NodeInstanceImpl.java:79)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
  at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
  at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167)
  at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94)
  at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  at java.util.concurrent.FutureTask.run(FutureTask.java:139)
  at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:38)
  at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
  at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
  at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:123)
  at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
  at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
  at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154)
  at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:126)
  at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:186)
  at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:109)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
  at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
  at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
  at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
  at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
  at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:176)

below is the LOC, to get nodename
System.out.println(("Node name "+((org.jbpm.workflow.instance.WorkflowProcessInstance)instance).getNodeInstances().iterator().next().getNodeName()));
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/789988#789988]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Maciej Swiderski
2013-01-10 10:47:50 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: Couldn't retrieve the node name for the process instance in JBPM 5.4"

To view the discussion, visit: https://community.jboss.org/message/790055#790055

--------------------------------------------------------------
if you use persistence you should make it as part of transaction and to do so you could use command like following:
String nodeName = ksession.execute(new GenericCommand<String>() {
    public String execute(Context context) {
        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
        org.jbpm.process.instance.ProcessInstance processInstance = (org.jbpm.process.instance.ProcessInstance) ksession.getProcessInstance(piId);
       
        return ((org.jbpm.workflow.instance.WorkflowProcessInstance)instance).getNodeInstances().iterator().next().getNodeName());
    }
});
 

Obviously it's simple case you could have a command that does all you need.

if you are looking for a way to get node names of active process instance you can use history log data for it and then you don't need to have anything else but processInstanceId, take a look at methods of this http://docs.jboss.org/jbpm/v5.4/javadocs/org/jbpm/process/audit/JPAProcessInstanceDbLog.html class

HTH
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/790055#790055]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
neeraj sharma
2013-01-14 15:37:52 UTC
Permalink
neeraj sharma [https://community.jboss.org/people/nsharm28] created the discussion

"Re: Couldn't retrieve the node name for the process instance in JBPM 5.4"

To view the discussion, visit: https://community.jboss.org/message/791626#791626

--------------------------------------------------------------
Thanks alot Maciej
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/791626#791626]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...