Unsatisfied rule fires - Drools bug?
by matvey1414
Hi,
I am working with Drools to implement a high-profile rules-engine. I have
two rules defined. Clearly, only the first should fire, but both do. Here is
my DRL:
package com.sample
import com.sample.DroolsTest.Request;
rule "ExpensiveCanonShopper0"
when
Request( attributeMap["camera0"] == "canon" &&
attributeMap["price0"] >= 500 )
then
System.out.println("ExpensiveCanonShopper0");
end
rule "ExpensiveCanonShopper1"
when
Request( attributeMap["camera1"] == "canon" &&
attributeMap["price1"] >= 500 )
then
System.out.println("ExpensiveCanonShopper1");
end
And the Java class to execute it:
public class DroolsTest {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static final void main(String[] args) {
try {
//Loading the Rules
System.out.println("Loading rules");
RuleBase ruleBase = readRule();
StatelessSession workingMemory =
ruleBase.newStatelessSession();
System.out.println("Firing rules");
Map map = new HashMap();
map.put("camera0", "canon");
map.put("price0", 600);
Request request = new Request();
request.setAttributeMap(map);
workingMemory.execute(request);
} catch (Throwable t) {
t.printStackTrace();
}
}
/**
* Please note that this is the “low level” rule assembly API.
*/
private static RuleBase readRule() throws Exception {
//read in the source
Reader source = new FileReader(new File("drl",
"Generated.drl"));
//optionally read in the DSL (if you are using it).
//Reader dsl = new InputStreamReader(
DroolsTest.class.getResourceAsStream( “/mylang.dsl” ) );
//Use package builder to build up a rule package.
//An alternative lower level class called “DrlParser” can
also be used…
PackageBuilder builder = new PackageBuilder();
//this wil parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is
for normal DRL.
builder.addPackageFromDrl( source );
if (builder.hasErrors()) {
PackageBuilderErrors errors = builder.getErrors();
throw new RuntimeException("Error adding package to
builder: " + errors.toString());
}
//Use the following instead of above if you are using a DSL:
//builder.addPackageFromDrl( source, dsl );
//get the compiled package (which is serializable)
Package pkg = builder.getPackage();
//add the package to a rulebase (deploy the rule package).
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}
public static class Request {
private Map attributeMap;
public Map getAttributeMap() {
return attributeMap;
}
public void setAttributeMap(Map attributeMap) {
this.attributeMap = attributeMap;
}
}
}
The output is this, meaning both rules fired:
Loading rules
Firing rules
ExpensiveCanonShopper1
ExpensiveCanonShopper0
I have two questions:
1. Is this a bug, or am I doing something wrong? Only
"ExpensiveCanonShopper0" should fire.
2. I am pretty sure this is somehow related to the fact that I'm using Map
attributes, and not POJO to get "price0" and "camera0". My issue is that I
won't know the parameters in advance (they are coming in a URL), so I can't
pre-declare them, and thus need something dynamic like a Map. Is this how
Drools is intended to be used? The documentation appears very POJO-centric.
I am using Drools 5.2
Thank you!
-Matt
--
View this message in context: http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp337...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
Getting Exception while running rules continuously on the Event Streams from Mule Component.
by Hari Kishan
Please find attached the rule Code (.drl) below.
Frequently getting this below Exception while running rules.
Exception caught while executing action:
org.drools.reteoo.PropagationQueuingNode$PropagateAction@41c317
java.lang.NullPointerException
at org.drools.util.LeftTupleList.toArray(LeftTupleList.java:106)
at org.drools.util.LeftTupleList.toArray(LeftTupleList.java:11)
at org.drools.reteoo.CollectNode.assertObject(CollectNode.java:256)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at
org.drools.reteoo.RightInputAdapterNode.assertLeftTuple(RightInputAdapterNode.java:135)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:28)
at org.drools.reteoo.FromNode.evaluateAndPropagate(FromNode.java:156)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:104)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:145)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:39)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:175)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at
org.drools.reteoo.PropagationQueuingNode$AssertAction.execute(PropagationQueuingNode.java:326)
at
org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:221)
at
org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:394)
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1486)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:158)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:122)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:80)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:28)
at org.mule.module.drools.Drools.assertEvent(Drools.java:165)
at org.mule.module.bpm.Rules.handleEvent(Rules.java:131)
at org.mule.module.bpm.RulesComponent.doInvoke(RulesComponent.java:84)
at
org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:120)
at
org.mule.component.AbstractComponent.access$000(AbstractComponent.java:56)
at
org.mule.component.AbstractComponent$1$1.process(AbstractComponent.java:234)
at
org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:88)
at
org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:89)
at
org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:63)
at
org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:89)
at
org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:94)
at
org.mule.component.AbstractComponent.process(AbstractComponent.java:154)
at
org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingMessageProcessor.java:93)
at
org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
at
org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:118)
at
org.mule.processor.SedaStageInterceptingMessageProcessor$SedaStageWorker.doWork(SedaStageInterceptingMessageProcessor.java:197)
at
org.mule.processor.SedaStageInterceptingMessageProcessor$SedaStageWorker.doRun(SedaStageInterceptingMessageProcessor.java:178)
at
org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:43)
at org.mule.work.WorkerContext.run(WorkerContext.java:309)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
http://drools.46999.n3.nabble.com/file/n3372189/sensors.drl sensors.drl
--
View this message in context: http://drools.46999.n3.nabble.com/Getting-Exception-while-running-rules-c...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
Job opening to work on Drools & jBPM in Argentina
by Mark Proctor
One of the largest healthcare organisations in Argentina is looking to
find two senior developers, full time, to work on Drools and jBPM. The
position is a long term contractual one and you must be based in Buenos
Aries, Argentina
The work is for R&D enhancements to Drools and jBPM, not for building
end user applications. It involves developing next generation authoring
environments for rules, workflow and the semantic web. The ideal
candidates would have a mixed set of skills including java, gwt and
javascript. Knowledge of Drools and jBPM is a plus, but not mandatory.
You will work day to day with the Drools and jBPM team, as part of their
community. All your work will be open source and you'll be able to
evangelise your work via community facilities, such as mailing lists and
blogs. This provides a unique opportunity to work on high profile
projects in a public manner and gain recognition for yourself and your work.
You can apply for the job here :
http://jobs.athico.com/job/senior-java-and-javascript-developer-to-work-o...
<http://jobs.athico.com/job/senior-java-and-javascript-developer-to-work-o...>
14 years, 5 months
Partial Unification / Derivation of Facts?
by JohnnyCaimbridge
NOTE: Reposted because I only just subscribed to the mailing list.
Hello,
I have a set of Fact types which represent factors matched and used
throughout the other rules. Each of these Fact types may be derived in a
variety of mutually exclusive ways--ie based on the line of business or
other factors. The rules are all well-defined for these Facts. Something
like this:
declare FactorType1
value : BigDecimal
end
rule "FactorType1"
when
LineOfBusiness( this == LineOfBusiness.LOB1 )
// some other conditions
$prms : Params() // ***provisional*** where to specify needed context
dependent parameters? see below
then
BigDecimal value = new BigDecimal("0");
// ... determine value based on conditions and $prms
insert( new FactorType1(value) );
end
// <some other mutually exclusive rules to derive FactorType1 here>
The problem is that in the rules which match these Facts, there are many
context dependent (ie *always* unique to that particular rule) parameters
which must be "passed" to the derivation of those Facts. I'm referring to
these as "Params" above. Now, a rule that uses FactorType1:
rule "a rule that uses FactorType1"
when
// some conditions
FactorType1( $value )
$prms : Params(prm1,prm2,prm3,...) // ***provisional*** how to indicate
that FactorType1 should use these parameters in its derivation?
then
// perform some calculation with $value
end
The parameters which these Facts use cannot be asserted as Facts themselves.
They are unique to the rules which match on the FactorTypes, so that would
mean I'd need a duplicate rule for every rule that uses a FactorType (even
with "rule inheritance", this is excessive).
It's almost as if I need to specify a "partial derivation" or "partial
unification" of the Fact type, which is only asserted once a rule indicates
that it is providing the "unbound" portion of the derivation. I understand
queries can be used for some sort of partial unification, but I have no clue
how to apply them to my problem and I can't find any good examples or
documentation on their usage/behavior.
Thanks in advance
--
View this message in context: http://drools.46999.n3.nabble.com/Partial-Unification-Derivation-of-Facts...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
java.lang.IncompatibleClassChangeError: Found interface org.drools.reteoo.LeftTuple, but class was expected
by danielje
Hello drools users.
I'm developing a project that uses drools and jbpm2. I have a simple jbpm2
diagram that contains a few workItems, ruleflow groups and gateways.
I'm getting the following exception when the process flow goes into first
ruleflow-group:
java.lang.IncompatibleClassChangeError: Found interface
org.drools.reteoo.LeftTuple, but class was expected
2011-09-22 08:54:09,125 INFO [STDOUT]
(org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) at
tele2Demo.Rule_Load_Data_Tray_0DefaultConsequenceInvoker.evaluate(Rule_Load_Data_Tray_0DefaultConsequenceInvoker.java:17)
2011-09-22 08:54:09,125 INFO [STDOUT]
(org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:906)
2011-09-22 08:54:09,125 INFO [STDOUT]
(org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:845)
2011-09-22 08:54:09,125 INFO [STDOUT]
(org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) at
org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1056)
...
The problem occurs only when I read a ChangeSet.xml from remote guvnor
repository.
When I read rules from local path the error does not occur.
The jars I use:
drools-compiler :5.2.0.Final
drools-core :5.2.0.Final
drools-persistence-jpa :5.2.0.Final
knowledge-api-5.2.0.Final
jbpm-bpmn2-5.1.0.Final
jbpm-flow-5.1.0.Final
jbpm-flow-builder-5.1.0.Final
jbpm-persistence-5.1.0.Final
I verified the history of LeftTuple and indeed it was a class in all 5.2.0
release beside the Final where it was changed to interface.
Does anyone here have any idea how to get rid of this error? Are newer
versions of jppm packages using LeftTuple interface instead of class?
Best regards
/danielje
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-IncompatibleClassChangeError-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
Maven Drools Plugin needs proper de-serialization support from DroolsStreamUtils
by Ansgar Konermann
Hi all,
I think I've found a bug in DroolsStreamUtils.
It does not allow to deserialize a collection of KnowledgePackages with
dependencies between the packages. In this case, it fails with
ClassNotFoundException.
Example: Package A contains a type declaration, package B contains a
rule using this declaration. Compilation and serialization works fine,
but deserialization fails (complains that it cannot find declared type).
As it seems, the deserialization code does not consider classes
resulting from declared types when resolving type references.
This is true for Drools 5.2.0.Final, 5.3.0.CR1 and 5.3.0.Beta1. It works
fine for 5.1.1.
I was so bold to create a JIRA ticket for this problem right away:
https://issues.jboss.org/browse/JBRULES-3225 (with unit tests attached).
The functionality provided by class DroolsStreamUtils is essential for
the Maven Drools Plugin (compiler needs to serialize stuff, which then
needs to be *de-serializable* by applications).
If anyone is interested in using the upcoming Maven Drools Plugin to
compile rule source code into binary package files and *load* theses
packages from your application, please *vote* for this JIRA ticket, as
the maven plugin *must* rely on serialization functionality *provided by
drools* (a re-implementation is certainly out of scope and would be
more than "prone" to incompatibility). Without a fix or at least a
workaround for this bug, the maven plugin will only be able to work with
Drools 5.1.1 (newer versions are broken, older versions did not include
DroolsStreamUtils at all AFAIK).
Thanks in advance, to everyone who will contribute to a potential
solution or workaround.
Best regards
Ansgar
14 years, 5 months
How to terminate a StatefulKnowledgeSession
by bishopmm
I'm using Drools to build a wizard app within a web application. The
StatefulKnowledgeSession runs within its own thread. After loading the
rules, I call fireAllRules() to start the knowledge session. Within the
wizard app, the user has the option to click on a cancel button in order to
stop the wizard. When the user cancels the wizard, a rule is fired that
attempts to stop the knowledge session. I've tried calling drools.halt() and
drools.getWorkingMemory().clearAgenda() from within that rule, but
fireAllRules() doesn't return, and the thread is left hanging. What do I
need to do to get fireAllRules() to return? I'm fairly new to Drools, and I
apologize in advance if I've missed something blatantly obvious.
Thanks,
Mike
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-terminate-a-StatefulKnowledgeSes...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
Weird human task behaviour
by HMandic
I have this strange problem, when I call
int taskId = 105; // dummy taskId, the real one is obtained
through TaskSummary
BlockingTaskOperationResponseHandler b = new
BlockingTaskOperationResponseHandler();
client.complete(taskId, "myusername", null, b);
while (!b.isDone()){
b.waitTillDone(100);
}
System.out.println("Completed task "+taskId+" owned by user
myusername.");
I get this in the log:
INFO [STDOUT] Completed task 105 owned by user myusername.
INFO [STDOUT] Notification of completed task 104
...and about 50 milliseconds later...
INFO [STDOUT] Notification of aborted task 104
No error messages between these two notifications.
I understand that these ID's are not the same because 104 is actually
workItemId that holds taskId 105.
The status of task 105 in the database table "task" is "Completed", but the
workflow stops after it and I can't do anything about it.
Is there any known issues with task persistence in JBoss 5.1 or something?
--
View this message in context: http://drools.46999.n3.nabble.com/Weird-human-task-behaviour-tp3368608p33...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months