[jboss-user] [jBPM] - Re: getProcess in ProcessInstanceImpl throws a NullPointerException

Sandra Renaud do-not-reply at jboss.com
Thu Apr 4 12:22:38 EDT 2013


Sandra Renaud [https://community.jboss.org/people/joploya] created the discussion

"Re: getProcess in ProcessInstanceImpl throws a NullPointerException"

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

--------------------------------------------------------------
Anyone to help please?

I don't succed to debug this.

This is the code of knowledgeSession producer :

log.debug("produce the KnowledgeSession ...");

                    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

List<Resource> resources = getProcessDefinitionList();
                    for (Resource resource : resources) {
                              kbuilder.add(resource, ResourceType.BPMN2);
                    }

                    if ( kbuilder.hasErrors() ) {
                         log.error( kbuilder.getErrors().toString() );
                     }
                    KnowledgeBase kbase = kbuilder.newKnowledgeBase();

                    Environment env = KnowledgeBaseFactory.newEnvironment();
                    env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );

                    if(kbase != null){
                              System.out.println("knowledge base NOT null");
                              for(org.drools.definition.process.Process p :kbase.getProcesses()){
                                        System.out.println(" - process "+p.getName()+" ["+p.getId()+"]");
                              }


                    }

                    StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
                    System.out.println(" !!!! DEBUG SESSION PERSISTENCE : new session with id : "+ksession.getId()+" !!!!");

And the associated log :

knowledge base NOT null
 - process newcpbeforem29commontrunk [com.st.ams.flows.newcpbeforem29commontrunk]
 - process newcpbeforem29 [com.st.ams.flows.newcpbeforem29]
 - process newfinishedgood [com.st.ams.flows.newfinishedgood]
 - process DataCorrections [com.st.ams.flows.datacorrections]
 - process newproductline [com.st.ams.flows.newproductline]
Hibernate:
    insert
    into
        SessionInfo
        (lastModificationDate, rulesByteArray, startDate, OPTLOCK)
    values
        (?, ?, ?, ?)
 !!!! DEBUG SESSION PERSISTENCE : new session with id : 32 !!!!

After that I try to retrieve all tasks and display task information. This use the method below :

public Object getProcessVariable(Long processInstanceId, Long taskId, String key){
                    Object retObj = null;
                    WorkflowProcessInstance wpi = (WorkflowProcessInstance)kSession.getProcessInstance(processInstanceId);
                    if((wpi == null) || (wpi.getVariable(key) == null)){
                              System.out.println("workflow process instance is null :-(");
                    }else{
                              System.out.println("workflow process instance is NOT null :-)");
                              retObj = wpi.getVariable(key);

                              //node info
                              System.out.println("is knowledge runtime null? "+(kSession.getSessionClock() == null));

                              System.out.println("list of node instance : ");
                              for(NodeInstance iNode : wpi.getNodeInstances()){
                                        Node node = iNode.getNode();
                              }
                    }
                    return retObj;
          }

and the associated log :

workflow process instance is NOT null :-)
is knowledge runtime null? false
list of node instance :

but then I have the same error as for my first post in the ProcessInstanceImpl class

Caused by: java.lang.NullPointerException
          at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:68) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
          at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getWorkflowProcess(WorkflowProcessInstanceImpl.java:181) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
          at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getNodeContainer(WorkflowProcessInstanceImpl.java:69) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
          at org.jbpm.workflow.instance.impl.NodeInstanceImpl.getNode(NodeInstanceImpl.java:103) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]
          at com.st.ams.task.management.TaskManager.getProcessVariable(TaskManager.java:234) [classes:]

It may be the kruntime that is null but how it is null?
--------------------------------------------------------------

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

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130404/549b75a2/attachment.html 


More information about the jboss-user mailing list