<!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/806670#806670">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Lol, I'm looking forward to see your example about accessing metadatas!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To make the java code looks like java code, you must use the advanced editor :</p><pre class="jive-pre"><code class="jive-code">click on add response
then click on advanced editor at right up corner outside the editing panel and accept to exit the page (normally your text is not remove).
finally select the code click on &gt;&gt; button and highlighting.
</code></pre><p>Easy compare to implement Jbpm! <span> :) </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If I can abuse a little more of your patience, I will explain you why I have to set process variable :</p><p>I use them to set the userId and groupId at each step for the next step. So I already use the parameter map when I start process :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">Map&lt;String, Object&gt; variables = <font color="navy"><b>new</b></font> HashMap&lt;String, Object&gt;();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;variables.put(<font color="red">"flowId"</font>, entity.getFlowId());
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;variables.put(<font color="red">"flowType"</font>, entity.getFlowType().getFlowAcronym());
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;variables.put(<font color="red">"codifType"</font>, codifType);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;variables.put(<font color="red">"groupAssign"</font>, codifType+<font color="red">"_P_ENG"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;variables.put(<font color="red">"userAssign"</font>, userAssign);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;variables.put(<font color="red">"line"</font>, line);
&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;taskManager.startProcess(<font color="red">"com.st.ams.flows.newfinishedgood"</font>, variables);
</code></pre><pre class="jive-pre"><code class="jive-code jive-java"><font color="darkgreen">/**
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160; * Start a new processInstance of an existing Process
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160; * and set the variables of this instance
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160; * @param processId, map of variables
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160; * @return ProcessInstance created
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;<font color="navy"><b>public</b></font> ProcessInstance startProcess(String processId, Map&lt;String, Object&gt; parameters)<font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ProcessInstance p = kSession.startProcess(processId,parameters);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<font color="navy"><b>return</b></font> p;
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>But one of my main targets using jbpm is to manage dynamic assignement, and I was starting doing this with the methode setVariables :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>private</b></font> <font color="navy"><b>void</b></font> manageInstanceFgPlanStep2() <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;log.debug(<font color="red">"Normally this method is called after sending email : "</font> + <font color="red">"it validate the step 2"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;String userAssign = newFinishedGoodBean.getFlowEntity().getpEngPartEntity().getRecipientPoBeName();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;log.debug(<font color="red">" -&gt;userAssign = "</font>+userAssign); 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;taskManager.setProcessVariable(taskManager.getManageTask().getProcessInstanceId(), <font color="red">"userAssign"</font>, userAssign);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;taskManager.setProcessVariable(taskManager.getManageTask().getProcessInstanceId(), <font color="red">"groupAssign"</font>, 
&#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;&#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;<font color="red">"AMS_CRW_"</font>+newFinishedGoodBean.getFlowEntity().getOrganisationalEntity().getCodifType()+<font color="red">"_PO_BE"</font>); 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;taskManager.completeTask(taskManager.getManageTask(),<font color="navy"><b>null</b></font>); 
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This method to set variables worked very good until last week, I have test several flows from start to end... The major change I made is to persist session in database in order to retrive user task even if the application server crashes. So just one line :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
</code></pre><p>replace by </p><pre class="jive-pre"><code class="jive-code jive-java">StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Are you a Jbpm developer? That must be awesome to take part to this project.</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/806670#806670">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>