[rules-users] Global type integer - Unexpected global

Wolfgang Laun wolfgang.laun at gmail.com
Fri Mar 14 07:46:36 EDT 2014


The error you are getting occurs if the knowledge base doesn't
contain the global at all. - Do you check for compilation errors
after building? Does a simple rule

rule hello
when
then
   System.out.println( "Hello" );
end

fire if you add it to your DRL?

-W

On 14/03/2014, Faraniaina Domoina Rabarijaona
<rabarijaonadomoina at gmail.com> wrote:
> Hello,
>
> I have a global integer in my drl file and I use it in a rule like this:
>
> global int id;
>
> when
>            f: MyFact();
> then
>           MyClass mc=new MyClass();
>          mc.setId(id);
> end;
>
> On my java code, I have:
> int id=3
> ksession.setGlobal("id", id);
>
> But I get the error: Unexpected global [id].
> I just test without the global in the RHS, like this:
>
> then
>           MyClass mc=new MyClass();
>          int x=3;
>          mc.setId(x);
> end;
>
> It's working.
>
> What am I doing wrong ?
> I tried with the type Integer (java.lang.Integer), but same problem.
>
> If anyone can help me,
>
> Thanks,
>


More information about the rules-users mailing list