Discussion:
[jboss-user] [jBPM] - NullPointerException while executing knowledgeSession.getProcessInstance
sc_boss
2013-02-22 17:07:39 UTC
Permalink
sc_boss [https://community.jboss.org/people/sc_boss] created the discussion

"NullPointerException while executing knowledgeSession.getProcessInstance"

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

--------------------------------------------------------------
I'm looking at some code here in 5.4.0 (jbpm-flow/5.4.0.Final/jbpm-flow-5.4.0.Final-sources.jar):

org.jbpm.marshalling.impl.AbstractProtobufProcessInstanceMarshaller.readProcessInstance(MarshallerReaderContext)

it goes like this on line 373:

Process process = ruleBase.getProcess( processId );
if ( ruleBase != null ) {
     processInstance.setProcess( process );
}

Isn't this code incorrect? If rule base were to be null it would have failed on the first line itself.

May be the code should be:

if ( *process* != null ) {
     processInstance.setProcess( process );
}

Not sure.
I guess I'm running into this issue when i try to load the process instance:

ProcessInstance pid = ksession.getProcessInstance(16);

java.lang.NullPointerException
    at org.jbpm.process.instance.impl.ProcessInstanceImpl.setProcess(ProcessInstanceImpl.java:62)
    at org.jbpm.marshalling.impl.AbstractProtobufProcessInstanceMarshaller.readProcessInstance(AbstractProtobufProcessInstanceMarshaller.java:375)
    at org.jbpm.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:142)
    at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:91)
    at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:206)
    at org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1116)
    at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:297)
    at org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:48)
    at org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:25)
    at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)
    at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:373)
    at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getProcessInstance(CommandBasedStatefulKnowledgeSession.java:125)
    at com.sample.ProcessTest.main(ProcessTest.java:64)
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-02-22 19:13:16 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: NullPointerException while executing knowledgeSession.getProcessInstance"

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

--------------------------------------------------------------
What do you want to achieve by the code?
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
sc_boss
2013-02-22 20:26:10 UTC
Permalink
sc_boss [https://community.jboss.org/people/sc_boss] created the discussion

"Re: NullPointerException while executing knowledgeSession.getProcessInstance"

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

--------------------------------------------------------------
i want to get the process instance that i created in a session.
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-02-25 14:33:29 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: NullPointerException while executing knowledgeSession.getProcessInstance"

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

--------------------------------------------------------------
I dont know about the question you raised but I can give you other alternatives to get process related details. But it all depends on why you want the process instance object.

If you are creating the process in the same session then you can get the instance while starting the process.


ProcessInstance processInstance = ksession.startProcess(processDefId);


If you are saving the session then I believe you can save the process instance object too.

On the other hand if your Session is killed, and if you have the process instance id, which I believe you do have as I see the hardcoded value 16 in the code, you could use the following code to get process instance related details :



JPAProcessInstanceDbLog.findProcessInstance(id);


Regards.

Another way is to connect to the taskclient and getting the TaskSummary List object.

client.getTasksByStatusByProcessId(processInstanceId,statusList, "en-UK", responseHandler);
   taskSummaryList = responseHandler.getResults();
--------------------------------------------------------------

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

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