<!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="http://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;">
    Process variables, rules, Gateway constraints
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/GaryS">Gary Struthers</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/616560#616560">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I followed <span style="font-size: 12pt;"><a class="jive-link-message-small" href="http://community.jboss.org/message/607839#607839">Accessing process variables in rule-task</a> </span><a class="jive-link-external-small" href="http://community.jboss.org/message/607839#607839#607839" target="_blank">http://community.jboss.org/message/607839#607839</a></p><p>But I'm starting a new thread because I have new problems and that thread was marked as answered.</p><p>I'm missing something important about how to handle variables in rules and constraints but I can't find it.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>A JUnit4 test fails when I call fireAllRules()</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">org.drools.RuntimeDroolsException: Unexpected exception executing action org.jbpm.process.instance.event.DefaultSignalManager$SignalAction@3e4ac866</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1000)</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:733)</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:702)</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; color: #777777;"><span style="color: #000000;">&#160; </span>@Test<span style="color: #000000;"> </span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;<span style="color: #a5006a;">public</span> <span style="color: #a5006a;">void</span> assignApplication() <span style="color: #a5006a;">throws</span> Exception {</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; color: #229571;"><span style="color: #000000;">&#160; </span>// given </p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;StatefulKnowledgeSession kSession = createKnowledgeSession(getKbase());</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;String ready = <span style="color: #a5006a;">new</span> String(<span style="color: #4e00ff;">"false"</span>);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;String assignLHS = <span style="color: #a5006a;">new</span> String(<span style="color: #4e00ff;">"true"</span>);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Map&lt;String, Object&gt; params = <span style="color: #a5006a;">new</span> HashMap&lt;String, Object&gt;();</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;params.put(<span style="color: #4e00ff;">"ready"</span>, ready);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;params.put(<span style="color: #4e00ff;">"assignLHS"</span>, assignLHS);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ProcessInstance pi = kSession.startProcess(<span style="color: #4e00ff;">"dummy"</span>, params);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color: #a5006a;">this</span>.assertNodeTriggered(pi.getId(), <span style="color: #4e00ff;">"Start"</span>,<span style="color: #4e00ff;">"AddPiFact"</span>, <span style="color: #4e00ff;">"Assign Application"</span>);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;kSession.fireAllRules();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>AddPiFact is a script immediately after Start with this action:</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;"><span style="color: #bc0000;"><strong>import</strong></span> org.drools.runtime.KnowledgeContext</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;"><span style="color: #bc0000;"><strong>import</strong></span> org.drools.runtime.KnowledgeRuntime</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">kcontext.getKnowledgeRuntime().<span style="color: #bc0000;"><strong>insert</strong></span>(kcontext.getProcessInstance());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The rule is supposed to set "ready" if "assignLHS" is true</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;"><span style="color: #bc0000;">import</span> org.drools.runtime.process.WorkflowProcessInstance</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;"> <span style="color: #bc0000;">rule</span><span style="color: #000000;"> </span>"applicationReady"</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; color: #009800;"><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #bc0000;">ruleflow-group</span><span style="color: #000000;"> </span>"assignApplication"</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160; <span style="color: #bc0000;">when</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; $process: WorkflowProcessInstance()</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; $assignLHS :String() <span style="color: #bc0000;">from</span> (String)$process.getVariable(<span style="color: #009800;">"assignLHS"</span>);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #bc0000;">eval</span>($assignLHS == <span style="color: #009800;">"true"</span>);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160; <span style="color: #bc0000;">then</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; $process.setVariable(<span style="color: #009800;">"ready"</span>, <span style="color: #009800;">"true"</span>);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #bc0000;">update</span>($process);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; color: #bc0000;">end</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I want an XOR Gateway to use "ready" in its Constraints but if I write it like</p><p>return ready.compareIgnoreCase("true");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The KnowledgeBuilder has an error that "ready" can't be resolved.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/616560#616560">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://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>