[rules-users] Rule not compiling in IDE after migration to 5.2

Jamie jshaw at llbean.com
Wed Jul 20 14:29:24 EDT 2011


Thanks for pointing that out, Wolfgang.  I had stripped out some parentheses
during some testing.  We had them there in the 5.1.1 version.  They don't
seem to make a difference in 5.2.0 for the cases I've been working with.

In an attempt to create something stand-alone that I could share in response
to Manstis's reply, I found something very interesting.  It appears that the
trouble stems from a static initialization in one of the called classes that
retrieves a string value from a property file and parses it into an int.  I
was able to recreate the issue with a very simple example.  It doesn't even
matter if you refer to the variable in your code.  Here's are the classes:

    package com.test;

    import java.util.ResourceBundle;

    public class RuleTest {
	
        private static ResourceBundle resourceBundle =
ResourceBundle.getBundle("some file");
	
        public static String getSomeValue() {
            return "some value";
        }
    }


    package com.test;

    public class TestFact {
	
        public int getSomeValue() {
            return 17;
        }
    }

and here's the rule:

    package com.test

    rule "Test Rule"

        when
            $testFact: TestFact(someValue > (RuleTest.getSomeValue()));
        then
            //Do something useful

    end

If you remove the 'static' modifier from the resourceBundle variable
declaration above, the rule compiles fine in the IDE.  Note that it executes
fine with or without the static modifier when deployed.


--
View this message in context: http://drools.46999.n3.nabble.com/Rule-not-compiling-in-IDE-after-migration-to-5-2-tp3183689p3186253.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list