<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: getProcess in ProcessInstanceImpl throws a NullPointerException
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/joploya">Sandra Renaud</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/806531#806531">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Anyone to help please?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I don't succed to debug this.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This is the code of knowledgeSession producer :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>log.debug("produce the KnowledgeSession ...");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();</p><p>&#160; </p><p>&#160; <span style="font-size: 10pt;">List&lt;Resource&gt; resources = getProcessDefinitionList();</span></p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for (Resource resource : resources) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;kbuilder.add(resource, ResourceType.BPMN2);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if ( kbuilder.hasErrors() ) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; log.error( kbuilder.getErrors().toString() );</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;KnowledgeBase kbase = kbuilder.newKnowledgeBase();</p><p>&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Environment env = KnowledgeBaseFactory.newEnvironment();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );</p><p>&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if(kbase != null){</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println("knowledge base NOT null");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(org.drools.definition.process.Process p :kbase.getProcesses()){</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println(" - process "+p.getName()+" ["+p.getId()+"]");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</p><p>&#160; </p><p>&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</p><p>&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println(" !!!! DEBUG SESSION PERSISTENCE : new session with id : "+ksession.getId()+" !!!!");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And the associated log :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>knowledge base NOT null</p><p> - process newcpbeforem29commontrunk [com.st.ams.flows.newcpbeforem29commontrunk]</p><p> - process newcpbeforem29 [com.st.ams.flows.newcpbeforem29]</p><p> - process newfinishedgood [com.st.ams.flows.newfinishedgood]</p><p> - process DataCorrections [com.st.ams.flows.datacorrections]</p><p> - process newproductline [com.st.ams.flows.newproductline]</p><p>Hibernate:</p><p>&#160;&#160;&#160; insert</p><p>&#160;&#160;&#160; into</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; SessionInfo</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; (lastModificationDate, rulesByteArray, startDate, OPTLOCK)</p><p>&#160;&#160;&#160; values</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; (?, ?, ?, ?)</p><p> !!!! DEBUG SESSION PERSISTENCE : new session with id : 32 !!!!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>After that I try to retrieve all tasks and display task information. This use the method below :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>public Object getProcessVariable(Long processInstanceId, Long taskId, String key){</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Object retObj = null;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;WorkflowProcessInstance wpi = (WorkflowProcessInstance)kSession.getProcessInstance(processInstanceId);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if((wpi == null) || (wpi.getVariable(key) == null)){</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println("workflow process instance is null :-(");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}else{</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println("workflow process instance is NOT null :-)");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;retObj = wpi.getVariable(key);</p><p>&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//node info</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println("is knowledge runtime null? "+(kSession.getSessionClock() == null));</p><p>&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println("list of node instance : ");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(NodeInstance iNode : wpi.getNodeInstances()){</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Node node = iNode.getNode();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return retObj;</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>and the associated log :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>workflow process instance is NOT null :-)</p><p>is knowledge runtime null? false</p><p>list of node instance :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>but then I have the same error as for my first post in the ProcessInstanceImpl class</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Caused by: java.lang.NullPointerException</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:68) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getWorkflowProcess(WorkflowProcessInstanceImpl.java:181) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getNodeContainer(WorkflowProcessInstanceImpl.java:69) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.getNode(NodeInstanceImpl.java:103) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at com.st.ams.task.management.TaskManager.getProcessVariable(TaskManager.java:234) [classes:]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>It may be the kruntime that is null but how it is null? </p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/806531#806531">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>