Yes.. make sure that all the variables that you use at least in the left hand side of the expressions are declared.. so when you us it again it will be there..<br>Greetings!<br><br><div class="gmail_quote">On Sat, Dec 4, 2010 at 12:19 AM, Greg Barton <span dir="ltr">&lt;<a href="mailto:greg_barton@yahoo.com">greg_barton@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">My, aren&#39;t we snippy?<br>
<br>
OK, well if you read this then note that those rules shouldn&#39;t work in any environment for the reason previously stated.  (Use of an undeclared variable in the RHS.)  If they are working then something odd is going on, and since you say they are then...something odd is going on.<br>

<br>
BTW, the error you&#39;re getting now is an mvel error:<br>
<br>
<a href="http://mvel.codehaus.org/Strong+Typing+Mode" target="_blank">http://mvel.codehaus.org/Strong+Typing+Mode</a><br>
<br>
Since you&#39;re currently getting it for &quot;$severity&quot; and not just &quot;severity&quot; even though the former does not currently appear in your rule...well that&#39;s the odd bit I mentioned before.  Somewhere $severity (along with $weight, $factor, and $tempScore) is being declared, but it&#39;s not in the text of the rule as you&#39;ve provided it.<br>

<br>
GreG<br>
<div><div></div><div class="h5">On Dec 3, 2010, at 19:07, &quot;John McKim&quot; &lt;<a href="mailto:jmckim@comcast.net">jmckim@comcast.net</a>&gt; wrote:<br>
<br>
First off, yes, I am an expert Java programmer, not just a Drools expert - yet.  If you took the time to read the post, you would have found that the answer that was provided to me “DIDN’T WORK”.  Never mind, I’ll figure it out myself.  Goodby!    From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Greg Barton<br>

Sent: Friday, December 03, 2010 7:26 PM<br>
To: Rules Users List<br>
Subject: Re: [rules-users] Rules in App Server Error  You made the same error in three other places.  Fix them.  Are you familiar with the java language?<br>
<br>
GreG<br>
On Dec 3, 2010, at 15:15, &quot;John McKim&quot; &lt;<a href="mailto:jmckim@comcast.net">jmckim@comcast.net</a>&gt; wrote:Thanks for the reply Mauricio.  I tried what you said using this modified rule: rule &quot;medicalHistoryBleedingRiskFactors.gastritis rule&quot;salience 20    when        # find patients who indicated that they have MedicalHistoryBleedingRiskFactors: gastritis        $patient : Patient(medicalHistoryBleedingRiskFactors.gastritis &gt; 0)    then        String severity = $patient.medicalHistoryBleedingRiskFactors.gastritis;         $weight = 5;        $factor = .1;        $tempScore = $factor;        $tempScore = $tempScore * $weight;        $tempScore = $tempScore * $severity;        # Now add this risk score to the accumlated risk score        $patient.score = $patient.score + $tempScore;        $patient.problem = new String(&quot;MedicalHistoryBleedingRiskFactors.gastritis&quot;);end But I got this exception in the client (I<br>

 am using 5.1.1 by the way): Exception in thread &quot;Thread-4&quot; java.lang.RuntimeException: Unable to build expression for &#39;consequence&#39;: [Error: Failed to compile: 1 compilation error(s):  - (1,9) unqualified type in strict mode for: $severity][Near : {... Unknown ....}]             ^[Line: 1, Column: 0] &#39;        String severity = $patient.medicalHistoryBleedingRiskFactors.gastritis;         $weight = 5;        $factor = .1;        $tempScore = $factor;        $tempScore = $tempScore * $weight;        $tempScore = $tempScore * $severity;        // Now add this risk score to the accumlated risk score        $patient.score = $patient.score + $tempScore;        $patient.problem = new String(&quot;MedicalHistoryBleedingRiskFactors.gastritis&quot;);&#39; : [Rule name=&#39;medicalHistoryBleedingRiskFactors.gastritis rule&#39;]         at<br>

 com.kai.framework.plugins.ruleengine.LocalRuleEnginePlugin.createLevel1KnowledgeBase(LocalRuleEnginePlugin.java:107)        at com.kai.framework.plugins.ruleengine.LocalRuleEnginePlugin.access$100(LocalRuleEnginePlugin.java:22)        at com.kai.framework.plugins.ruleengine.LocalRuleEnginePlugin$InitializeRuleEngine.run(LocalRuleEnginePlugin.java:192) When I took out the String severity and used just $severity:  it works fine.  Just on the App server does it fail. From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Mauricio Salatino<br>

Sent: Friday, December 03, 2010 3:36 PM<br>
To: Rules Users List<br>
Subject: Re: [rules-users] Rules in App Server Error that&#39;s weird.. you are using a varible that you never define in the Right Hand Side.<br>
$severity was never defined. In the RHS remember that you can write pure java. So if you want a variable called severity you should declare it as:<br>
String severity = $patient.medicalHistoryBleedingRiskFactors.gastritis; Greetings. 2010/12/3 John McKim &lt;<a href="mailto:jmckim@comcast.net">jmckim@comcast.net</a>&gt;I&#39;m having a problem that I can&#39;t seem to figure out.  I have rules that run in a client program with no problem - about 125 rules in all.  When I try to run these same rules in an App Server (GlassFish) I get several rules (about 5) that have an error on initialization.  Here is the error message followed by the rule.<br>

<br>
*******************************************<br>
SEVERE: java.lang.RuntimeException: Unable to build expression for &#39;consequence&#39;: [Error: not a statement, or badly formed structure]<br>
[Near : {... $severity;<br>
                   ....}]<br>
                     ^<br>
[Line: 1, Column: 233] &#39;        $severity = $patient.medicalHistoryBleedingRiskFactors.gastritis;<br>
        $weight = 5;<br>
        $factor = .1;<br>
        $tempScore = $factor;<br>
        $tempScore = $tempScore * $weight;<br>
        $tempScore = $tempScore * $severity;<br>
        // Now add this risk score to the accumlated risk score<br>
        $patient.score = $patient.score + $tempScore;<br>
        $patient.problem = new String(&quot;MedicalHistoryBleedingRiskFactors.gastritis&quot;);<br>
&#39; : [Rule name=&#39;medicalHistoryBleedingRiskFactors.gastritis rule&#39;]<br>
**********************************************<br>
rule &quot;medicalHistoryBleedingRiskFactors.gastritis rule&quot;<br>
salience 20<br>
    when<br>
        # find patients who indicated that they have MedicalHistoryBleedingRiskFactors: gastritis<br>
        $patient : Patient(medicalHistoryBleedingRiskFactors.gastritis &gt; 0)<br>
    then<br>
        $severity = $patient.medicalHistoryBleedingRiskFactors.gastritis;<br>
        $weight = 5;<br>
        $factor = .1;<br>
        $tempScore = $factor;<br>
        $tempScore = $tempScore * $weight;<br>
        $tempScore = $tempScore * $severity;<br>
        # Now add this risk score to the accumlated risk score<br>
        $patient.score = $patient.score + $tempScore;<br>
        $patient.problem = new String(&quot;MedicalHistoryBleedingRiskFactors.gastritis&quot;);<br>
end As I said, this rule runs fine in a client app – when I run the same rules in app server I get an error.  This is only happening in 5 out of 125 rules, and only during initialization using builder.add(ResourceFactory.newClassPathResource(file).<br>

Thanks. <br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
--<br>
 - CTO @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a> <br>
 - MyJourney @ <a href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a><br>
 - Co-Founder @ <a href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br>
 <br>
 - Salatino &quot;Salaboy&quot; Mauricio -_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
</div></div><a href="https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________</a><br>

<div><div></div><div class="h5">rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br> - CTO @ <a href="http://www.plugtree.com">http://www.plugtree.com</a>  <br> - MyJourney @ <a href="http://salaboy.wordpress.com">http://salaboy.wordpress.com</a><br>
 - Co-Founder @ <a href="http://www.jbug.com.ar">http://www.jbug.com.ar</a><br> <br> - Salatino &quot;Salaboy&quot; Mauricio -<br>