Get the reason why certain rule failed to be activated.
by Meny Kobel
Hi,
In debug mode I need to write to my application log the reason why certain
rule failed to be activated.
I'm familiar with the "Audit view" but the data isn't sufficient. It doesn't
write the reason why rule wasn't activated only successful activation.
For example:
DRL file :
rule "rule1"
when
Person(name matches "gogo")
then
System.out.println("gogo");
End
In main class :
Person A = new Person("dodo");
Person b = new Person("gogo");
newStatefulSession.insert(A);
newStatefulSession.insert(c);
newStatefulSession.fireAllRules();
I would like to write to log something like:
Rule1 wasn't activated since the condition "dodo" matches "gogo" returned
false for object Person(dodo)...
Any idea how can I get the rule run results?
Thanks,
Meny
15 years, 7 months
Dynamic object structure Drools use case?
by Tina
I'm trying to get a handle on whether Drools is the right tool for the job
we have at hand. Based on what I've seen in the documents and examples, I
believe it could be, but that we're definitely taking a more difficult
path. Interested in thoughts from folks with more experience than me.
Our project is looking for a solution to let us deal with streaming data,
and determine whether each individual data item meets a rule's criteria. Each
data item implements an interface, but the properties available on the
concrete objects differ wildly. Also, each data item can be considered to
be composed of multiple levels of these data items. One of the fields on
the interface is a getParent field, which returns the data item one level
up. (In effect, we end up with a singly linked list.) If X is the object
which we have a direct handle to, X.parent = Y, and Y.parent = Z, we often
want to look at Z.field as part of our rule. I believe that the quirk here
is that, although the objects are JavaBeans, they are presented as an
interface which does not describe the property set of the bean. Thus, I
don't directly know that X's parent is Y, whose parent is of type Z, which
then has a property named 'foo'. (Beans here are essentially user-defined
structures for contributed code, and thus we have no real way of knowing
what properties are on a bean until we receive the bean. When the users use
the beans, they obviously know which bean they're working with. For us,
we're getting it downstream, and that bean could be any of a dynamically
growing variety, also with many different permutations of structures in the
linked list.)
As a practical matter, the interface has a method getField(String, String),
whihc allows us to access specific fields both in the local bean and in the
beans available up its list. That functionality is accomplished through
some reflection logic.
I've tried the following approach, but it "smells" wrong:
- Create adapter classes per rule, and, given a data item, insert the item
again, adapted with a bean that gives access to the specific fields. We
believe the # of rules will be 10 or less at any given time in the
operational system. This would require us to query the known rules, and
provide adapter classes for them, which seems completely counter to normal
patterns of use. However, it would allow us to use a bean approach. [Note
that although I've shown that inserting an event again has my desired
effect, I haven't yet figured out how to query the set of rules, and provide
adapter classes for each rule.]
I'm also considering a DSL approach, trying to determine if that would allow
me to somehow transform the problem.
Any insights or feedback would be wonderful. In-house, we don't yet have a
great depth of expertise with Drools, so I'm interested in tapping a broader
pool of knowledge and experience. I've only got access to Drools 4 in my
environment. I can try alternate approaches in Drools 5 at home, but can't
use that solution as yet for our problem space.
- Tina
15 years, 7 months
get list from map object
by Meny Kobel
Hi,
One of the class member of the fact is map<String,List>.
In the DRL file I need to get list from the map(I know the map key) and set
it to variable name $theList.
Then I need to check if some variable is memberof $theList
Can you please advice how to get the list from the map and set the $theList
variable?
For example :
public class Cheese
{
private String type;
private Map<String,List<Integer>> map;
public Cheese(String type) {
this.type = type;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Map<String, List<Integer>> getMap()
{
return map;
}
public void setMap(Map<String, List<Integer>> map)
{
this.map = map;
}
public List<Integer> getListFromMap(String name)
{
return map.get(name);
}
}
DRL file -
rule "Cheese_fans_18"
when
Cheese($theList :* don't know how to get the list from the map*)
Cheese(type memberof $theList)
then
System.out.println("Cool");
end
Thanks,
Meny
15 years, 7 months
RE: rules-users Digest, Vol 29, Issue 59
by Tom.E.Murphy@wellsfargo.com
Thanks for the reply, Edson.
After several hours, I finally tracked down the source of the issue. In one of our rules, the following appeared as part of the LHS:
$asset_count : Integer(intValue > 3) from accumulate (
Asset
(
// bunch of constraints....
) count())
The use of Integer here instead of Number was the root cause of the thrown exception.
The reason it was so hard to find is because this expression was being evaluated (I'm guessing) to determine whether the rule should be activated. Thus, even though we were monitoring activation events as well as insertions, de-activations, firings, etc. we were never able to see which rule was causing the issue - it would throw before any related events fired. And even in the debugger, the rule that was causing the exception could not be identified, as it was not visible from the various nodes and other data structures that comprise the internals of Drools RETE. At least, not visible to me, a total newbie on the internals.
Admittedly, this does not match the syntax shown in the Drools manual (which illustrates it using Number instead of Integer), but it would have been a big time saver if the Drools parser could have rejected this as a syntax error or alerted us to the questionable usage in some way. In a rule base of several hundred complex rules, it was a nightmare to find.
I don't know whether you still want a JIRA for this or not, since technically it resulted from a rules coding error - ??
Thanks again.
Tom Murphy
Business Process Consultant
Wells Fargo HCFG - CORE Deal Decisioning Platform
800 S. Jordan Creek Parkway | West Des Moines, IA 50266
MAC: X2301-01B
Office: 515 324 4853 | Mobile: 941 320 8014
This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of rules-users-request(a)lists.jboss.org
Sent: Tuesday, April 21, 2009 2:57 AM
To: rules-users(a)lists.jboss.org
Subject: rules-users Digest, Vol 29, Issue 59
Send rules-users mailing list submissions to
rules-users(a)lists.jboss.org
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
rules-users-request(a)lists.jboss.org
You can reach the person managing the list at
rules-users-owner(a)lists.jboss.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-users digest..."
Today's Topics:
1. Re: Question: Why is ClassFieldReader.getIntValue throwing
in this scenario? (Edson Tirelli)
2. Re: Drools 3.0.6 - Not able to execute more than one rule -
Stucked up (Vir)
3. Drools 3.0.6 with OC4J (Vir)
4. "==" operator does not work on float and double type (Zeke)
----------------------------------------------------------------------
Message: 1
Date: Mon, 20 Apr 2009 22:05:34 -0400
From: Edson Tirelli <tirelli(a)post.com>
Subject: Re: [rules-users] Question: Why is
ClassFieldReader.getIntValue throwing in this scenario?
To: Rules Users List <rules-users(a)lists.jboss.org>
Message-ID:
<e6dd5ba30904201905t3cf1fe25td9b6a43b9224ba4c(a)mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"
Sounds like a bug... it should be casting to Number instead of Integer.
Can you open a JIRA with a test case or a way to reproduce the problem?
Thanks,
Edson
2009/4/20 <Tom.E.Murphy(a)wellsfargo.com>
> The following block of code inside org.drools.base.ClassFieldReader is
> throwing an exception and I don?t quite understand why. Can anyone advise?
> Thanks in advance.
>
> *public* *int* getIntValue(InternalWorkingMemory workingMemory,
> *final* Object object) {
> *return* *this*.reader.getIntValue( workingMemory,
> object );
> }
>
> Object is of type Long, with value = 0, when the throw happens, and
> workingMemory is null (having been explicitly passed in as null by the
> method two layers up in the stack:
>
> *public* *boolean* isAllowed(*final* InternalReadAccessor readAccessor,
> *final* InternalFactHandle handle,
> *final* InternalWorkingMemory workingMemoiry,
> *final* ContextEntry context) {
> *return* *this*.evaluator.evaluate( *null*,
> *this*.readAccessor,
> handle.getObject(),
> *this*.field );
> }
>
>
> While sitting on the breakpoint in getIntValue, the live call stack is as
> follows:
>
> ClassFieldReader.getIntValue(InternalWorkingMemory, Object) line: 164
> ComparableEvaluatorsDefinition$IntegerGreaterEvaluator.evaluate(InternalWorkingMemory,
> InternalReadAccessor, Object, FieldValue) line: 1881
> LiteralRestriction.isAllowed(InternalReadAccessor, InternalFactHandle,
> InternalWorkingMemory, ContextEntry) line: 92
> LiteralConstraint.isAllowed(InternalFactHandle, InternalWorkingMemory,
> ContextEntry) line: 109
> AccumulateNode.evaluateResultConstraints(LeftTuple, PropagationContext,
> InternalWorkingMemory, AccumulateNode$AccumulateMemory,
> AccumulateNode$AccumulateContext) line: 498
> AccumulateNode.assertLeftTuple(LeftTuple, PropagationContext,
> InternalWorkingMemory) line: 197
> SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(PropagationContext,
> InternalWorkingMemory, LeftTuple) line: 117
> SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(LeftTuple, RightTuple,
> PropagationContext, InternalWorkingMemory, boolean) line: 28
> JoinNode.assertObject(InternalFactHandle, PropagationContext,
> InternalWorkingMemory) line: 175
> CompositeObjectSinkAdapter.doPropagateAssertObject(InternalFactHandle,
> PropagationContext, InternalWorkingMemory, ObjectSink) line: 366
> CompositeObjectSinkAdapter.propagateAssertObject(InternalFactHandle,
> PropagationContext, InternalWorkingMemory) line: 349
> AlphaNode.assertObject(InternalFactHandle, PropagationContext,
> InternalWorkingMemory) line: 147
> SingleObjectSinkAdapter.propagateAssertObject(InternalFactHandle,
> PropagationContext, InternalWorkingMemory) line: 42
> AlphaNode.assertObject(InternalFactHandle, PropagationContext,
> InternalWorkingMemory) line: 147
> SingleObjectSinkAdapter.propagateAssertObject(InternalFactHandle,
> PropagationContext, InternalWorkingMemory) line: 42
> AlphaNode.assertObject(InternalFactHandle, PropagationContext,
> InternalWorkingMemory) line: 147
> CompositeObjectSinkAdapter.doPropagateAssertObject(InternalFactHandle,
> PropagationContext, InternalWorkingMemory, ObjectSink) line: 366
> CompositeObjectSinkAdapter.propagateAssertObject(InternalFactHandle,
> PropagationContext, InternalWorkingMemory) line: 342
> ObjectTypeNode.assertObject(InternalFactHandle, PropagationContext,
> InternalWorkingMemory) line: 184
> EntryPointNode.assertObject(InternalFactHandle, PropagationContext,
> ObjectTypeConf, InternalWorkingMemory) line: 146
> ReteooStatefulSession(AbstractWorkingMemory).insert(InternalFactHandle,
> Object, Rule, Activation, ObjectTypeConf) line: 1066
> ReteooStatefulSession(AbstractWorkingMemory).insert(Object, boolean,
> boolean, Rule, Activation) line: 1022
> DefaultKnowledgeHelper.insert(Object, boolean) line: 103
> DefaultKnowledgeHelper.insert(Object) line: 97
> Rule_RS6601_3_2_0.consequence(KnowledgeHelper, TransactionDetail,
> FactHandle, Double, FactHandle, DealRiskCategoryEnum$Enum, FactHandle,
> ExitStrategyTypeEnum$Enum, FactHandle, Short, FactHandle, Short, FactHandle)
> line: 32
> Rule_RS6601_3_2_0ConsequenceInvoker.evaluate(KnowledgeHelper,
> WorkingMemory) line: 42
> DefaultAgenda.fireActivation(Activation) line: 934
> DefaultAgenda.fireNextItem(AgendaFilter) line: 885
> DefaultAgenda.fireAllRules(AgendaFilter, int) line: 1082
> ReteooStatefulSession(AbstractWorkingMemory).fireAllRules(AgendaFilter,
> int) line: 682
> ReteooStatefulSession(AbstractWorkingMemory).fireAllRules() line: 649
> StatefulKnowledgeSessionImpl.fireAllRules() line: 177
> RuleBase.runTestCase(LoanFile, String, int, Logger) line: 116
>
>
>
> *Tom Murphy
> **Business Process Consultant
> Wells Fargo HCFG - CORE Deal Decisioning Platform
> 800 S. Jordan Creek Parkway | West Des Moines, IA 50266
> MAC: **X2301-01B
> **Office: **515 324 4853** | Mobile: 941 320 8014
> **This message may contain confidential and/or privileged information. If
> you are not the addressee or authorized to receive this for the addressee,
> you must not use, copy, disclose, or take any action based on this message
> or any information herein. If you have received this message in error,
> please advise the sender immediately by reply e-mail and delete this
> message. Thank you for your cooperation.*
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
15 years, 7 months
RuleBase deserialization throws NPE
by dhai
We have application that has two parts. One is for authoring the rules and
deploying RuleBase into database. Second reads that sterilized RuleBase from
database and evaluate the rules. I am randomly getting NPE while I
desterilize RuleBase. Its very inconsistent. The test data and environment
in same. Once I get one NPE while performing 2000 transactions and second
time I receive same exception after 500 transactions. The first test was
executed in single threaded and second was in multi threaded.
I was wondering if some one else had encounter same problem. There trace is:
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.NullPointerException
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1820)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at
org.drools.common.AbstractRuleBase.doReadExternal(AbstractRuleBase.java:257)
at
org.drools.reteoo.ReteooRuleBase.readExternal(ReteooRuleBase.java:151)
at
java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1755)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1717)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at
net.dharis.net.rules.RulesResolverImpl.resolveFor(RulesResolverImpl.java:48)
--
View this message in context: http://www.nabble.com/RuleBase-deserialization-throws-NPE-tp23147611p2314...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 7 months
ProviderInitializationException in creating KnowledgeBuilder
by Brody bach
Hi all,
I'm using CR1 version of drools and when I tried to create KnowledgeBuilder:
if (rulePackage.exists()) {
final KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newFileResource(rulePackage),
ResourceType.PKG);
.....
I got the ProviderInitializationException as follows:
09:38:18,125 ERROR [test.drools.common.ejb.ExceptionInterceptor] [] Provider
org.drools.builder.impl.KnowledgeBuilderProviderImpl could not be set.
org.drools.ProviderInitializationException: Provider
org.drools.builder.impl.KnowledgeBuilderProviderImpl could not be set.
at
org.drools.builder.KnowledgeBuilderFactory.loadProvider(KnowledgeBuilderFactory.java:111)
at
org.drools.builder.KnowledgeBuilderFactory.getKnowledgeBuilderProvider(KnowledgeBuilderFactory.java:101)
at
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:29)
I use drools-core and drools-api in the project and I found out that the
class Provider org.drools.builder.impl.KnowledgeBuilderProviderImpl doesn't
even exist. Do I miss any package?
And a second question, when will the javadoc of drools be online again? ;-)
Thanks
Brody
--
View this message in context: http://www.nabble.com/ProviderInitializationException-in-creating-Knowled...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 7 months
Drools 3.0.6 - Not able to execute more than one rule
by Vir
Hi All,
I am new to drools. I am using Drools 3.0.6. When I execute just one
rule, it works fine. But when I run the same file with 2 or more rules, at
runtime in console the SOPs stops at
org.apache.commons.jci.compilers.JaninoJavaCompiler - compiling
com.tcs.sgv.apps.requesthandler.services.Rule_Credit_Denied_0
Same example works fine in Eclipse and both rules are executed, but my
constraints are jDeveloper, jdk1.4, OC4J. Can someone help me out
Following is my .java file code
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(new
InputStreamReader(CreditExample.class.getResourceAsStream("/abc.drl")));
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(builder.getPackage());
WorkingMemory workingMemory = ruleBase.newWorkingMemory();
Person child = new Person("Person 1", 15);
Person adult = new Person("Person 2", 25);
workingMemory.assertObject(adult);
workingMemory.assertObject(child);
workingMemory.fireAllRules();
Following is my .drl file
rule "Credit Allowed"
when
person:Person(age >= 18)
then
System.out.println("Credit allowed for " + person.getName());
end
rule "Credit Denied"
when
deniedPerson:Person(age < 18)
then
System.out.println("Credit denied for " + deniedPerson.getAge());
end
Thanks for any solution/replies
Regards
Vir
--
View this message in context: http://www.nabble.com/Drools-3.0.6---Not-able-to-execute-more-than-one-ru...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 7 months
Question: Why is ClassFieldReader.getIntValue throwing in this scenario?
by Tom.E.Murphy@wellsfargo.com
The following block of code inside org.drools.base.ClassFieldReader is throwing an exception and I don't quite understand why. Can anyone advise? Thanks in advance.
public int getIntValue(InternalWorkingMemory workingMemory,
final Object object) {
return this.reader.getIntValue( workingMemory,
object );
}
Object is of type Long, with value = 0, when the throw happens, and workingMemory is null (having been explicitly passed in as null by the method two layers up in the stack:
public boolean isAllowed(final InternalReadAccessor readAccessor,
final InternalFactHandle handle,
final InternalWorkingMemory workingMemoiry,
final ContextEntry context) {
return this.evaluator.evaluate( null,
this.readAccessor,
handle.getObject(),
this.field );
}
While sitting on the breakpoint in getIntValue, the live call stack is as follows:
ClassFieldReader.getIntValue(InternalWorkingMemory, Object) line: 164
ComparableEvaluatorsDefinition$IntegerGreaterEvaluator.evaluate(InternalWorkingMemory, InternalReadAccessor, Object, FieldValue) line: 1881
LiteralRestriction.isAllowed(InternalReadAccessor, InternalFactHandle, InternalWorkingMemory, ContextEntry) line: 92
LiteralConstraint.isAllowed(InternalFactHandle, InternalWorkingMemory, ContextEntry) line: 109
AccumulateNode.evaluateResultConstraints(LeftTuple, PropagationContext, InternalWorkingMemory, AccumulateNode$AccumulateMemory, AccumulateNode$AccumulateContext) line: 498
AccumulateNode.assertLeftTuple(LeftTuple, PropagationContext, InternalWorkingMemory) line: 197
SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(PropagationContext, InternalWorkingMemory, LeftTuple) line: 117
SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(LeftTuple, RightTuple, PropagationContext, InternalWorkingMemory, boolean) line: 28
JoinNode.assertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory) line: 175
CompositeObjectSinkAdapter.doPropagateAssertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory, ObjectSink) line: 366
CompositeObjectSinkAdapter.propagateAssertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory) line: 349
AlphaNode.assertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory) line: 147
SingleObjectSinkAdapter.propagateAssertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory) line: 42
AlphaNode.assertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory) line: 147
SingleObjectSinkAdapter.propagateAssertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory) line: 42
AlphaNode.assertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory) line: 147
CompositeObjectSinkAdapter.doPropagateAssertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory, ObjectSink) line: 366
CompositeObjectSinkAdapter.propagateAssertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory) line: 342
ObjectTypeNode.assertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory) line: 184
EntryPointNode.assertObject(InternalFactHandle, PropagationContext, ObjectTypeConf, InternalWorkingMemory) line: 146
ReteooStatefulSession(AbstractWorkingMemory).insert(InternalFactHandle, Object, Rule, Activation, ObjectTypeConf) line: 1066
ReteooStatefulSession(AbstractWorkingMemory).insert(Object, boolean, boolean, Rule, Activation) line: 1022
DefaultKnowledgeHelper.insert(Object, boolean) line: 103
DefaultKnowledgeHelper.insert(Object) line: 97
Rule_RS6601_3_2_0.consequence(KnowledgeHelper, TransactionDetail, FactHandle, Double, FactHandle, DealRiskCategoryEnum$Enum, FactHandle, ExitStrategyTypeEnum$Enum, FactHandle, Short, FactHandle, Short, FactHandle) line: 32
Rule_RS6601_3_2_0ConsequenceInvoker.evaluate(KnowledgeHelper, WorkingMemory) line: 42
DefaultAgenda.fireActivation(Activation) line: 934
DefaultAgenda.fireNextItem(AgendaFilter) line: 885
DefaultAgenda.fireAllRules(AgendaFilter, int) line: 1082
ReteooStatefulSession(AbstractWorkingMemory).fireAllRules(AgendaFilter, int) line: 682
ReteooStatefulSession(AbstractWorkingMemory).fireAllRules() line: 649
StatefulKnowledgeSessionImpl.fireAllRules() line: 177
RuleBase.runTestCase(LoanFile, String, int, Logger) line: 116
Tom Murphy
Business Process Consultant
Wells Fargo HCFG - CORE Deal Decisioning Platform
800 S. Jordan Creek Parkway | West Des Moines, IA 50266
MAC: X2301-01B
Office: 515 324 4853 | Mobile: 941 320 8014
This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.
15 years, 7 months