Trouble with shadow proxies, insertLogical, and WorkingMemoryListener
by A Gattiker
I have an interface called InducedFact. Rules use insertLogical to
insert instances of implementing classes, and a working memory
listener allows me to control the application when those facts are
inserted and removed.
However in some cases, the fields of my InducedFact class have been
changed to null when my event listener's 'objectRetracted' method is
called, although they have been properly initialized upon
'objectInserted'. Even the debugger could not see when the fields were
set back to null. I have not been able to create a simple test case to
reproduce it, however.
Excluding the implementing classes from shadow proxying does solve the
problem. However it is a bit inconvenient to have to give the full
list of implementing classes (passing the interface name with the code
below doesn't work). Also, the rule base may have been serialized, and
I would have to recreate it every time I create a new InducedFact
implementing class.
RuleBaseConfiguration rbConf = new RuleBaseConfiguration();
rbConf.setShadowProxy(true);
rbConf.setShadowProxyExcludes(InducedFact.class.getName());
Wouldn't it be more flexible to configure the working memory elsewhere
than in the rule base configuration?
Thanks in advance for your insights.
18 years, 5 months
Drools Puzzles round 1 result
by Drools Puzzle
Hi all,
many thanks to all the participators in the round 1 and congratulations to
the winner Dr. Starke. I'll post a detailed report with current scores of
all participators and comments to each solution to Drools wiki tomorrow. Now
it's Dr. Starke's turn to post the next puzzle.
Happy drooling!
Drools Puzzle
18 years, 5 months
Drools 4.0 Migrating
by Saleem Lakhani
Hi,
I am very new to Drools. I need to know from where I can get some
resources on DSL Syntax in 4.0. Examples etc. I am working on a project
which used Drools 3 and my job is to upgrade it to 4.0. I am able to get
everything compiled but getting stuck at loading DSLs. For example: I am
getting an exception like:
An exception occurred while attempting to parse a Validation rule in
ABC
Failed to add the compiled rule package to the RuleBase cause by: Unable
to resolve ObjectType 'orRiskTO' : [Rule name=Certificate]
Unable to resolve ObjectType 'orRiskTO' : [Rule name=Certificate,
agendaGroup=Rating, salience=0, no-loop=false]
Rule Compilation error : [Rule name=Dwellings, agendaGroup=Rating,
salience=0, no-loop=false]
rating/Rule_Dwellings_0.java (36:39) : A method named
"intValue" is not declared in any enclosing class nor any supertype, nor
through a static import
at org.drools.rule.Package.checkValidity(Package.java:409)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:262)
at
com.citizens.ratebook.RatebookRuleBaseFactory.buildValidationsRulebase(R
atebookRuleBaseFactory.java:168)
... 29 more
thanks
Saleem Lakhani
18 years, 5 months
Guided DRL editor
by kissro@lidp.com
Hello,
I am new to JBoss rules and was wondering if someone could explain how
to get started with the new Guided DRL Editor. I'm using Drools 4.0 and
the Eclipse IDE. I've clicked on 'New Guided DRL editor' in Eclipse and
it's created the rules.brxml file. The editor is on the screen showing
'If', 'Then', and 'Options' but it's blank. I've selected the 'If' and
clicked on little screen with the '+' on the right side of the editor.
A dialog box opens with 'Add a New Condition' and a drop down box for
'Fact' but the only option in the drop down box is 'Choose a Fact'.
I've also selected 'Then' and clicked on little screen with the '+' on
the right side of the editor. A dialog box opens with 'Add a New
Action' and several drop down boxes. The only option in all of the
drop down boxes is 'Choose'.
How do I get these boxes populated? I've already got several existing
rules coded and I thought they would show up in the editor but they
don't. Do I have to code the rules in Java before I can use the editor?
According to what I've read, this is supposed to be a point-and-click
way of creating rules but so far I haven't seen that. I was hoping to
be able to use the editor as sort of a gui for creating or modifying my
rules but haven't been able to figure out how to do that. Any help
would be appreciated.
Rod
18 years, 5 months
trivial case in xls
by Bin Shen (BA/EDD)
Hi, all,
use 4.0.0 GA.
want to have an xls rule file. i am not sure of how to define the following trivial case in xls.
can anybody help? thanx!
when
$p : Person()
then
// do something with any person
end
/ Ben
18 years, 5 months
Decision tables with cutoff time
by Hehl, Thomas
I'm trying to create a decision table. One of the rules is that an event
must occur a certain number of days before another event. This number of
days before cutoff currently means that anytime before the cutoff date is
allowed, but anything on or after the cutoff date is not. I'm trying to
modify this to allow things that are actually on the cutoff date are allowed
if they happen before a certain time in the day, to allow for customers that
want cutoff to be until close of business or some such.
Can I put this into a decision table?
Thanks.
Thom Hehl
Sr. eJuror Architect
* Office (859) 277-8800 x 144
* Thomas.Hehl(a)acs-inc.com <mailto:Thomas.Hehl@acs-inc.com>
ACS, Inc.
Government Solutions
1733 Harrodsburg Road
Lexington, KY 40504-3617
This e-mail message, including any attachments, is for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the sender
by reply e-mail and destroy all copies of the original message and notify
sender via e-mail at Thomas.Hehl(a)acs-inc.com
<mailto:Thomas.Hehl@acs-inc.com> or by telephone at 859-277-8800 ext. 144.
Thank you.
18 years, 5 months
RE: trivial case in xls
by Bin Shen (BA/EDD)
sorry, i used the wrong word "action", instead of "data".
take the schema once more to avoid misunderstanding (assume no grouped rows).
-------------------------------------------
| CONDITION
-------------------------------------------
object type/ | $p : Person
-------------------------------------------
snippet/condition | ?
-------------------------------------------
explaination text | xxxxxxxxx
-------------------------------------------
cell/data | ?
-------------------------------------------
it's clear: the condition ("snippet" in my term) can not be empty, and the data ("cell" in my term) can be empty.
in my case how should i put the condition, when no field constraint is there? how should i put in the data? an empty invalidates the condition!
the case i raised seems trivial. actually it finds many applications as follows. in question comes the rule "otherwise":
rule "main"
salience 10
when
$p : Person(age > 35)
then
// do something with persons older than 35
System.out.println("hello, " + $p + "!");
end
rule "otherwise"
when
$p : Person()
then
// ignore other persons, i.e. retract them to avoid memory leaks
retract($p);
end
/ Ben
18 years, 5 months
RuntimeDroolsException
by Raffaele Viola
Hi,
I'm starting to use eclipse plug.in for JRules. I created the example JRules
project in eclipse and I tried to start it as Java Application but I got
this exception
org.drools.RuntimeDroolsException: Unable to load dialect '
org.drools.rule.builder.dialect.java.JavaDialect:java'
at org.drools.compiler.PackageBuilderConfiguration.buildDialectRegistry(
PackageBuilderConfiguration.java:156)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:131)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:84)
at com.sample.DroolsTest.readRule(DroolsTest.java:50)
at com.sample.DroolsTest.main(DroolsTest.java:21)
Can someone help me?
Thanks
Raffo
18 years, 5 months
Please help - losing hair
by Richard Hoberman
I'm using Drools 4 (M2), which is supposed to support nested accessors*
This works: when Claim( submissionInfo == null), but not this: when
Claim( submissionInfo.date == null)
Rule file, SubmissionInfo.java and exception are below.
What am I missing?
Richard
* See
http://article.gmane.org/gmane.comp.java.drools.user/8079/match=nested+pr...,
which states "Support to nested accessors, property navigation and
simplified collection, arrays and maps syntax"
Rule File
---------------------------------------------------------------------------------------
package mvanamibia.claim;
import java.lang.Object;
import java.lang.String;
import java.lang.Double;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import com.sadalbari.mvanamibia.beans.Claim;
import com.sadalbari.mvanamibia.beans.Mandate;
import com.sadalbari.mvanamibia.beans.SubmissionInfo;
import com.sadalbari.mvanamibia.inspector.ClaimEvaluation;
global ClaimEvaluation evaluation;
rule "hasDateReceived"
when
Claim( submissionInfo.date == null )
then
evaluation.getFailures().add("missing: date received");
end
-----------------------------------------------------------------------------------
Exception
-----------------------------------------------------------------------------------
org.drools.rule.InvalidRulePackage: [19,23]: unknown:19:23 mismatched
token: [@137,471:471='.',<69>,19:23]; expecting type RIGHT_PAREN
at org.drools.rule.Package.checkValidity(Package.java:368)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:250)
at
com.sadalbari.mvanamibia.model.UnregisteredClaimValidationTest.setupWorkingMemory(UnregisteredClaimValidationTest.java:33)
at
com.sadalbari.mvanamibia.model.UnregisteredClaimValidationTest.testMandateClaim(UnregisteredClaimValidationTest.java:56)
... Removed 22 stack frames
FAILED: testEmptyClaim
org.drools.rule.InvalidRulePackage: [19,23]: unknown:19:23 mismatched
token: [@137,471:471='.',<69>,19:23]; expecting type RIGHT_PAREN
at org.drools.rule.Package.checkValidity(Package.java:368)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:250)
at
com.sadalbari.mvanamibia.model.UnregisteredClaimValidationTest.setupWorkingMemory(UnregisteredClaimValidationTest.java:33)
at
com.sadalbari.mvanamibia.model.UnregisteredClaimValidationTest.testEmptyClaim(UnregisteredClaimValidationTest.java:42)
... Removed 22 stack frames
------------------------------------------------------
SubmissionInfo (relevant bits)
public class SubmissionInfo implements Serializable {
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
18 years, 5 months
Problems Extending the Golfer example - Cartesian joins ??
by Simon French
Hi,
After attending a session with Mark Proctor in London I was inspired to play
around with Drools in a slightly different way than we use it for in the
workplace, and try and solve a puzzle.
Unfortunately I couldn't get Drools to solve it as I kept getting memory
problems (I believe are cartesian joins being the problem),
so I decided to extend the golfer example to see if I got the same problem
I added two new names and a new integer property, club
// create all possible Golfer objects
String[] names = new String[] { "Fred", "Joe", "Bob", "Tom",
"Des", "Terry" };
String[] colors = new String[] { "red", "blue", "plaid",
"orange","black", "white" };
int[] positions = new int[] { 1, 2, 3, 4, 5, 6 };
int[] clubs = new int[] {9,8,7,4,5,5};
for ( int n = 0; n < names.length; n++ ) {
for ( int c = 0; c < colors.length; c++ ) {
for ( int p = 0; p < positions.length; p++ ) {
for ( int q = 0; q < clubs.length; q++ ) {
session.insert(new Golfer( names[n],
colors[c], positions[p], clubs[q]) );
....
Then changed the golder.drl to:
package com.sample
import com.sample.Golfer;
rule "Golfer Riddle"
when
// A golfer named Fred,
Golfer( name == "Fred",
$fredsPosition : position, $fredsColor : color, $fredsClub :
club )
// Der Golfer hinter Fred trägt blau
Golfer( $unknownsName : name != "Fred",
$unknownsPosition : position == ( $fredsPosition + 1 ),
$unknownsColor : color == "blue", color != $fredsColor,
$unknownsClub : club == 5 )
// Joe steht an zweiter Stelle
Golfer( name == "Joe", $joesPosition : position == 2,
position != $fredsPosition,
$joesColor : color != $fredsColor,
$joesClub : club == 5 )
// Bob traegt Karo
Golfer( name == "Bob",
name != $unknownsName,
$bobsPosition : position != $fredsPosition,
position != $unknownsPosition, position !=
$joesPosition,
$bobsColor : color == "plaid",
color != $fredsColor, color != $joesColor,
color != $unknownsColor,
$bobsClub : club < $joesClub )
// Tom ist nicht 1. oder 4., traegt kein Orange
Golfer( $tomsName : name == "Tom",
$tomsPosition : position != 1, position != 4,
position != $fredsPosition, position != $joesPosition,
position != $bobsPosition,
$tomsColor : color != "orange", color != "blue",
color != $fredsColor, color != $joesColor,
color != $bobsColor )
Golfer ( $des : name == "Des", $desPosition : position <
$fredsPosition, $desColor : color != "blue",
color != $fredsColor, color != $joesColor,
color != $bobsColor )
Golfer ( $terry : name == "Terry", $terryPosition : position <
$desPosition, $terryColor : color != "blue",
color != $fredsColor, color != $joesColor,
color != $bobsColor )
then
System.out.println( "Fred " + $fredsPosition + " " + $fredsColor );
System.out.println( "Joe " + $joesPosition + " " + $joesColor );
System.out.println( "Bob " + $bobsPosition + " " + $bobsColor );
System.out.println( "Tom " + $tomsPosition + " " + $tomsColor );
System.out.println( "Des " + $desPosition + " " + $desColor );
System.out.println( "terry " + $terryPosition + " " + $terryColor
);
end
After a couple of minutes of processing I got:-
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
I also changed java memory allocation with -Xms1640M -Xmx1640M (The most I
can allocate on my PC), and tried running it as a stateless session too.
Is there anything else I can do, or is this simply pushing drools too far
(surely not!!) ?
I'm very keen on pushing this technology as much as possible in our
workplace and I'd really appreciate any help.
Thanks in advance
Simon
18 years, 5 months