drools

Drools: NullPointerException when addPackageFromDrl(source) is called

笑着哭i 提交于 2019-12-11 09:53:05
问题 I'm trying to execute a simple HelloWorld rule within an OSGi application. During parsing and compiling however, the following exception occurs: java.lang.NullPointerException at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:47) at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446) at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304) at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167) The DRL file is found by the

drools stateless vs stateful session

最后都变了- 提交于 2019-12-11 09:48:30
问题 When should I use Drools stateless session and what are the benefits of using it instead of stateful session? In some comment here it's said that stateless sessions wraps a stateful one, does it means that when I destory the statfeul session after firing all rules would behave like a stateful one ? 回答1: Perhaps it would be better to say that both (stateful) KieSession and StatelessKieSessions provide APIs (interfaces) to classes based on class AbstractRuntime. A StatelessKieSession provides

In drools can I access the working memory (or arbitrary facts) from within an AgendaFilter?

大憨熊 提交于 2019-12-11 09:45:43
问题 I'm using an AgendaFilter to decide whether a rule activation should be executed or not. As part of my working memory's facts I insert one "rule configuration" fact per rule which contains how often my rule is allowed to be executed (and a corresponding counter). I noticed that Match.getFactHandles() only returns the facts that 'created this match' (as per java doc). Is there a way to access the WorkingMemory and all its facts or do I basically have to declare my "rule configuration" fact as

How to create a score from several drools decision tables?

拥有回忆 提交于 2019-12-11 09:40:14
问题 I'm new to drools and trying to use guvnor to build a simple Framingham score calculator. An example is: lets say you are a 30yo male, you start with -9 points. If your total cholesterol is 180, add 4 points, if your a smoker add 8 points, if your HDL cholesterol is over 60, subtract 1 point, and if your blood pressure is 135 then add 1 point. Giving you a result of +3. The tables on the score sheet seem like a great scenario for a drools decision table(s). I'm having trouble figuring out how

Drools Constraint object other than P is found in collection

妖精的绣舞 提交于 2019-12-11 09:01:41
问题 I have been trying to figure this out on and off for a really long time. I can imagine a lot of very verbose and non-droolsy ways to go about accomplishing this. However, I would like to know the best practice for dealing with a situation like this. I would like to know how to write the constraint I describe below in the drools dialect. I wish to write a constraint that deals with a collection. Let's say we have CustomType which has a field Collection. The constraint should express we want to

Drools : Firing Rules using a Session vs WorkingMemory

夙愿已清 提交于 2019-12-11 08:39:05
问题 What is the difference in between these two in Drools ?? Means taht we can fire the rules based on the Creating the WorkingMemory from the loaded Rules RulesBase and firing rules as shown below : WorkingMemory workingmemory = rulebase.newWorkingMemory(); workingmemory.fireAllRules(); vs Using a Session (Stateful . Stateless ) to fire the rules as shown KnowledgeBase knowledgebase = createKnowledgeBase(); StatefulKnowledgeSession session = knowledgebase.newStatefulKnowledgeSession(); session

Stateless Vs Stateful Session behavior in drools

安稳与你 提交于 2019-12-11 08:11:10
问题 I am new to the drools. I was trying to understand the difference between Stateless and Stateful sessions provided by Drools. As per my initial understanding, In case of Stateless session, if fact is modified during action execution of any rule then it will not be re-submitted to inference engine to find out the new rules which matches the modified fact. In case of Stateful session, if fact is modified during action execution of any rule then it will be re-submitted to inference engine to

Illegal class for global expected com.package.sameobj found com.package.sameobj

寵の児 提交于 2019-12-11 07:54:10
问题 I'm integrating Spring with Drools but I have a problem with the global variables. When I run my code as Java Application there are not problems but if I run my code as Spring Application I got Illegal class for global expected com.package.sameobj found com.package.sameobj Error Running as Java Application, everything ok: package com.softarts.app; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import org.springframework.context

I just upgraded to drools 5 and the xml rules will not load

廉价感情. 提交于 2019-12-11 07:32:02
问题 When upgrading to drools 5, valid drools 4 xml rules do not work. Drools just throws an unhelpful null pointer exception. What can the problem be? 回答1: The problem is that Drools 5 changed the namespace. Replace xmlns="http://drools.org/drools-4.0" with xmlns="http://drools.org/drools-5.0" and at least for simple rules that is all you need. I hope that helps save someone the headache I just got dealing with this undocumented change. 来源: https://stackoverflow.com/questions/3314292/i-just

StatelessKnowledgeSession Focus Agenda

泪湿孤枕 提交于 2019-12-11 07:08:51
问题 I have a problem with a rules execution in drools, when I execute the rules with a StatefulKnowledgeSession there aren't problems: final KnowledgeBase kbase = knowledgeAgent.getKnowledgeBase(); final StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession(); session.getAgenda().getAgendaGroup("Third").setFocus(); session.getAgenda().getAgendaGroup("Second").setFocus(); session.getAgenda().getAgendaGroup("First").setFocus(); session.execute(CommandFactory.newBatchExecution