Rule extends doens't work correctly

584 views
Skip to first unread message

yacine...@gmail.com

unread,
Feb 20, 2015, 9:07:25 AM2/20/15
to drools...@googlegroups.com
Hi all,

I have two drools files :

file1.drl :

package name.pkg

import ex.sample.drools.*;

rule "Parent"
enabled true
when
    $person:Person(age==10)
then
   
end


file2.drl :

package name.pkg

import ex.sample.drools.*;

rule "
rule1" extends "Parent"
no-loop true
when
    Person(age==11)
then

end

rule "
rule2" extends "rule1"
no-loop true
when
    Person(age==12)
then

end


The file1.drl is compiled first then the file2.drl is compiled.

I got the following error :

Unable to resolve parent rule, please check that both rules are in the same package : [Rule name='rule2']
Unresolved parent name rule1 >> did you mean any of :[rule1]


But when i declare the drools file as following it's works:

file1.drl :

package name.pkg

import ex.sample.drools.*;

rule "Parent"
enabled true
when
    $person:Person(age==10)
then
   
end


rule "rule1" extends "Parent"
no-loop true
when
    Person(age==11)
then

end



file2.drl :

package name.pkg

import ex.sample.drools.*;

rule "rule2" extends "
rule1"
no-loop true
when
    Person(age==12)
then

end

Davide Sottara

unread,
Feb 22, 2015, 8:49:14 PM2/22/15
to drools...@googlegroups.com
 I could not reproduce the issue, could you please your full test case?
In particular, how do you build the kiebase exactly? (kmodule.xml, programmatically, or.. ?)
Also, which version are you using?
Thanks
Davide

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/b0dff690-0c92-426a-af5e-aff7382e111f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

yacine...@gmail.com

unread,
Feb 25, 2015, 5:56:36 AM2/25/15
to drools...@googlegroups.com
Hi David,

You can find the attached maven project that's perform this issue. I'm using drools version 6.1.0.
You can run ExampleDrools.java as java application.

Yacine
wod-drools-test.7z

Mario Fusco

unread,
Feb 27, 2015, 9:16:59 AM2/27/15
to drools...@googlegroups.com
Hi Yacine,

the way you're using to build the knowledge base is wrong.
Please use the new Drools 6 API. I modified your project and resending it in attachment. As you can see there, the new API are far more convenient and straightforward.

Cheers,
Mario

wod-drools-test.zip

yacine...@gmail.com

unread,
Mar 2, 2015, 4:39:33 AM3/2/15
to drools...@googlegroups.com
Hi Mario,

Thank you for your help. I now that my example is not a good way to build a session. But it's due to the history of our application. Anyway, the version with kmodule.xml is currently on developpement. I'll use it differently until using the kmodule.
This issue is closed for me ;-).

Yacine.
Reply all
Reply to author
Forward
0 new messages