3 Replies Latest reply on Feb 25, 2013 9:33 AM by Shobhit Tyagi

    NullPointerException while executing knowledgeSession.getProcessInstance

    sc_boss Newbie

      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)