NullPointerException when updating a fact
by schenka7
Hi dear drools team,
I've got a strange problem and hope someone can help me. I'm using drools
5.5.0.
I have some rules to validate user input. These will set the valid flag on a
fact to false and insert a Message fact into working memory that will
contain a message and a reference to the causing fact.
I also have a rule to retract Messages for facts which are not invalid
anymore.
I observe a NullPointerException originating at
DefaultAgenda.createActivation() when I perform following steps:
Insert a valid FirstName and call session.fireAllRules().
Change the FirstName to become invalid, call session.update() on it and call
session.fireAllRules().
The rule for retracting messages is the cause for the problem.
My question is, how can I fix it? Or is there a better way to manage error
messages?
Thank you
--
View this message in context: http://drools.46999.n3.nabble.com/NullPointerException-when-updating-a-fa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Controlling Rule Execution
by jking527467
All,
I'm new to Drools and I'm faced with what seems to be a pretty trivial task
that's taken a lot longer than expected.
I'm working mainly with distances and am looking for an plain English
response to this trivial problem.
Here's the problem:
- Activate all things within x miles.
- If nothing is within x miles, activate all things within y miles.
It seems pretty straight forward but here's my dilemma. If I execute on y
miles first, everything within x miles will also be activated. I need to
ensure the things between x and y miles aren't activated if anything is
within x miles of a certain fact.
Does this make any sense to anyone? I'm have a hard time grasping the
proper approach and have looked into activation groups, etc. but haven't had
any luck.
Any help is GREATLY appreciated!!!
Thanks in advance!
Jason
--
View this message in context: http://drools.46999.n3.nabble.com/Controlling-Rule-Execution-tp4025231.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
How to Call RuleFLow from Servlet
by josh
Drools 5.0
Server Tomcat
I am not able to call RuleFlow from servlet. It doesn’t throw any error, nor
shows the output. However I am able to call single rule(SampleRule.drl.DRL).
Below is the snapshot for the same.
/private RuleBase readRule() throws Exception {
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(new InputStreamReader(
TestServlet1.class.getResourceAsStream( "/com/sample/SampleRule.drl" ) ) );
builder.addRuleFlow( new
InputStreamReader(TestServlet1.class.getResourceAsStream(
"/com/sample/sampleruleflow.rf" ) ) );
Package pkg = builder.getPackage();
// add the package to a rulebase (deploy the rule package).
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);
return ruleBase;
}
/
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-Call-RuleFLow-from-Servlet-tp402...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Any API accessing to the rule logic instead of only Facts
by Sean Su
Does anyone know a public Drools API that we can use to access to the
actual rule logic in a structured way? Current we can use
AgendaEventListener and WorkingMemoryEventListener to access the facts
using in LHS and the objects used in RHS. But my project has some special
requirements which need to access the actual rule logic on LHS for auditing
and justification purpose.
For example, if a rule is like this:
when fact.list contains "123"
then do something.
When this rule is fired, not only do I need to know what the fact object
is, I also need to know the condition of this rule is involved a "contains"
API, with value "123".
Thanks in advance.
Sean
12 years, 4 months
Questions On Rule Flow
by josh
I am from WODM background and have a question on rule flow
1). Why do I need to add all the rules or decision tables to the
KnowledgeBuilder object? I have created rule flow with multiple task (rule
task # 1 for myRule1.drl, rule task # 2 for myTable.xls). Shouldn’t it take
all the elements from the rule task automatically that has been added to the
rule flow like WODM does?
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
DecisionTableConfiguration config =
KnowledgeBuilderFactory.newDecisionTableConfiguration();
config.setInputType(DecisionTableInputType.XLS);
kbuilder.add(ResourceFactory.newClassPathResource("myRule1.drl",myClas.class),
ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("myTable.xls"),ResourceType.DTABLE,
config);
kbuilder.add(ResourceFactory.newClassPathResource("myRuleFlow.rf",myClas.class),
ResourceType.DRF);
2). Why do I need to give ‘RuleFlowGroup” in my decision table. If I am
executing table it should execute all the rows based on their condition?
What is the usage of RuleFlowGroup?
3). What is the benefit of using reusable Subtask within rule flow?
Thanks in Advance
--
View this message in context: http://drools.46999.n3.nabble.com/Questions-On-Rule-Flow-tp4025223.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
IntelliFest 2013 (San Diego) - only 10 weeks to go
by Mark Proctor
http://blog.athico.com/2013/07/intellifest-2013-san-diegl-only-10.html
----
Here is the updated flyer for IntelliFest 2013, this October in San Diego. Dr. Ernest Friedman-Hill, the creator ofJess, will be there talking about the new Jess 8.0 release. Also Dr. Daniel Miranker, the creator of the Leaps algorithm (a lazy alternative to the Rete algorithm), will be there talking about web scale distributed pattern matching.
I'll also be there presenting my new algorithm, entitled "From Eager to Lazy : The Evolution of the Rete Algorithm
12 years, 4 months
Why the drools modified object does not reflect the changes when I call the remote web service?
by Nuwan Bandara
When I use the local drools rules instance, object gets updated and
reflects the changes accordingly but when I use the remote web service call
to use the remote drools engine, rules get executed correctly but updated
values does not get reflected back in the return object.
Environment into:
- JBoss 5
- Uses XLS decision table for the drools rules file
- Front end uses jbosseap5 and back-end users JBoss 5
Currently I have drools engine running on front end server (referred as
local) and back-end server (referred as remote) both. When I call the local
drools engine it works. But when I call the remote server through REST web
server function get executed correctly but updated values are not in the
object when it comes back to the front end.
Here’s the function that I use in the decision table (.xls)
function boolean setCTCFlag(Object resultViewMapObj, String siteCode){
boolean flag = false;
Map<String, ResultView> resultViewMap = (Map<String, ResultView>)
resultViewMapObj;
List<ResultView> resultViewList = new ArrayList<ResultView>();
resultViewList = new ArrayList<ResultView> (resultViewMap.values());
ResultView resultView = new ResultView();
resultView = resultViewList.get(0);
if(resultView.getSampleView().getSample() != null){
String sampleInd =
resultView.getSampleView().getSample().getSampleIndicator();
if(sampleInd != null && sampleInd.length() != 0){
String[] sampleIndComp = sampleInd.split(""[^\\w\\s]"");
for(int i = 0; i<sampleIndComp.length; i++){
LabelValueView labelValueView = new
LabelValueView();
labelValueView.setLabel(sampleIndComp[i].trim());
labelValueView.setValue(" ");
// DOTO: this is the issue
// folowing line gets executed but changes do
not get reflected in the object.
// Only happens when this called remotely.
resultView.getDynamicFields().put("CTC_CLIENT_FLAG", labelValueView);
flag = true;
}
}
}
return flag;
}
12 years, 4 months