My, aren't we snippy?

OK, well if you read this then note that those rules shouldn'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.

BTW, the error you're getting now is an mvel error:

http://mvel.codehaus.org/Strong+Typing+Mode

Since you're currently getting it for "$severity" and not just "severity" even 
though the former does not currently appear in your rule...well that's the odd 
bit I mentioned before.  Somewhere $severity (along with $weight, $factor, and 
$tempScore) is being declared, but it's not in the text of the rule as you've 
provided it. 

GreG
On Dec 3, 2010, at 19:07, "John McKim" <[email protected]> wrote:

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: [email protected] 
[mailto:[email protected]] On Behalf Of Greg Barton
Sent: Friday, December 03, 2010 7:26 PM
To: Rules Users List
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?

GreG
On Dec 3, 2010, at 15:15, "John McKim" <[email protected]> wrote:Thanks for 
the reply Mauricio.  I tried what you said using this modified rule: rule 
"medicalHistoryBleedingRiskFactors.gastritis rule"salience 20    when        # 
find patients who indicated that they have MedicalHistoryBleedingRiskFactors: 
gastritis        $patient : Patient(medicalHistoryBleedingRiskFactors.gastritis 
> 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("MedicalHistoryBleedingRiskFactors.gastritis");end But I got this 
exception in the client (I
 am using 5.1.1 by the way): Exception in thread "Thread-4" 
java.lang.RuntimeException: Unable to build expression for 'consequence': 
[Error: Failed to compile: 1 compilation error(s):  - (1,9) unqualified type in 
strict mode for: $severity][Near : {... Unknown ....}]             ^[Line: 1, 
Column: 0] '        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("MedicalHistoryBleedingRiskFactors.gastritis");' : [Rule 
name='medicalHistoryBleedingRiskFactors.gastritis rule']         at
 
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: [email protected] 
[mailto:[email protected]] On Behalf Of Mauricio Salatino
Sent: Friday, December 03, 2010 3:36 PM
To: Rules Users List
Subject: Re: [rules-users] Rules in App Server Error that's weird.. you are 
using a varible that you never define in the Right Hand Side.
$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:
String severity = $patient.medicalHistoryBleedingRiskFactors.gastritis; 
Greetings. 2010/12/3 John McKim <[email protected]>I'm having a problem that I 
can'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. 

******************************************* 
SEVERE: java.lang.RuntimeException: Unable to build expression for 
'consequence': [Error: not a statement, or badly formed structure] 
[Near : {... $severity; 
                   ....}] 
                     ^ 
[Line: 1, Column: 233] '        $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("MedicalHistoryBleedingRiskFactors.gastritis"); 
' : [Rule name='medicalHistoryBleedingRiskFactors.gastritis rule'] 
********************************************** 
rule "medicalHistoryBleedingRiskFactors.gastritis rule" 
salience 20 
    when 
        # find patients who indicated that they have 
MedicalHistoryBleedingRiskFactors: gastritis 
        $patient : Patient(medicalHistoryBleedingRiskFactors.gastritis > 0) 
    then 
        $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("MedicalHistoryBleedingRiskFactors.gastritis"); 
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).
Thanks. 
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users


-- 
 - CTO @ http://www.plugtree.com  
 - MyJourney @ http://salaboy.wordpress.com
 - Co-Founder @ http://www.jbug.com.ar
 
 - Salatino "Salaboy" Mauricio -_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users



      

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to