Guvnor 5.5.0.Final with IE and Firefox issues
by Sean Su
Do we have existing issues being tracked for "Guided Rule Editor" in Guvnor
5.5.0.Final not working on IE? The same Editor opened fine with Firefox.
Also noticed, even though the editor can be opened in Firefox, the "Load
Template Data" button in the "rule template" seems not working. There is no
visible response after it is clicked.
Unfortunately, I can't test this on IE as I could not open the "editor" in
the first place.
Sean
11 years, 7 months
Error adding new rule at Runtime drools 5.4.0.Final
by Tushar
Hi all,
I am using Drools-Fusion v5.4.0.Final. My use case is to add rules
dynamically at runtime which should get automatically updated in the
KnowledgeSession. Rules in my application are defined as DTO. I have
written a toDrl() method which returns a String which essentially is a rule
in drl. I use following code to add it to the already running instance of
rule engine.
*Initialize Rule Engine
*KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
if(kBase != null){
kBase.addKnowledgePackages(kBuilder.getKnowledgePackages());
}
// Populate rules from DB
List<AlertDefinitionDto> alertDefs = getDbRules();
for(AlertDefinitionDto alertDef : alertDefs) {
addRule(alertDef);
}
StatefulKnowledgeSession kSession = kBase.newStatefulKnowledgeSession();
*Add Rule
* try {
rwl.lock();
// Create new rule from AlertDefinitionDto
kBuilder.add(org.drools.io.ResourceFactory.newByteArrayResource(alertDef.toDrl().getBytes()),
org.drools.builder.ResourceType.DRL);
if(kBuilder.hasErrors()) {
kBuilder.undo();
KnowledgeBuilderErrors errs = kBuilder.getErrors();
System.err.print(AlertGenerationServiceImpl.class, "Error
adding rule : "+alertDef.getName());
String errorStr = "";
for (KnowledgeBuilderError error : errs) {
errorStr = errorStr + error.getMessage()+"\\n";
}
System.err.print("Error adding new rule: "+errorStr);
}
} finally {
rwl.unlock();
}
*
*
* *// No errors. Update KnowledgeBase.
try {
Collection<KnowledgePackage> kPkgs =
kBuilder.getKnowledgePackages();
kBase.addKnowledgePackages(kPkgs);
} catch (RuntimeException e) {
if(kBase.getRule(RULE_PACKAGE_NAME, alertDef.getName()) !=
null) {
kBuilder.undo();
}
e.printStackStrace();
}
*
*
*Fire Rules
*
* *LogMessage logMsg = getLog();*
*
kSession.insert(logMsg);
kSession.fireAllRules();
This code works fine under all conditions for initialization where rules
are fetched from DB and rule engine is initialized.
The code fails to add new rule dynamically, when the rule engine is already
initialized and fired few number of times with LogMessage as fact. The
errors which I am getting are
------------------------------------------------------------------
1. For the first time when it fails to add new rule.
------------------------------------------------------------------
java.lang.RuntimeException: Null accessor on node: null
at
org.drools.rule.constraint.ConditionAnalyzer.analyzeNode(ConditionAnalyzer.java:229)
at
org.drools.rule.constraint.ConditionAnalyzer.analyzeSingleCondition(ConditionAnalyzer.java:126)
at
org.drools.rule.constraint.ConditionAnalyzer.analyzeCondition(ConditionAnalyzer.java:102)
at
org.drools.rule.constraint.ConditionAnalyzer.analyzeCombinedCondition(ConditionAnalyzer.java:134)
at
org.drools.rule.constraint.ConditionAnalyzer.analyzeCondition(ConditionAnalyzer.java:94)
at
org.drools.rule.constraint.ConditionAnalyzer.analyzeCondition(ConditionAnalyzer.java:73)
at
org.drools.rule.constraint.MvelConditionEvaluator.getAnalyzedCondition(MvelConditionEvaluator.java:78)
at
org.drools.rule.constraint.MvelConstraint.getListenedPropertyMask(MvelConstraint.java:273)
at org.drools.reteoo.AlphaNode.calculateDeclaredMask(AlphaNode.java:372)
at org.drools.reteoo.ObjectSource.initDeclaredMask(ObjectSource.java:151)
at org.drools.reteoo.AlphaNode.<init>(AlphaNode.java:86)
at
org.drools.reteoo.builder.PatternBuilder.attachAlphaNodes(PatternBuilder.java:323)
at
org.drools.reteoo.builder.PatternBuilder.attachPattern(PatternBuilder.java:162)
at org.drools.reteoo.builder.PatternBuilder.build(PatternBuilder.java:80)
at
org.drools.reteoo.builder.GroupElementBuilder$AndBuilder.build(GroupElementBuilder.java:113)
at
org.drools.reteoo.builder.GroupElementBuilder.build(GroupElementBuilder.java:71)
at
org.drools.reteoo.builder.ReteooRuleBuilder.addSubRule(ReteooRuleBuilder.java:155)
at
org.drools.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:128)
at org.drools.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:116)
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:445)
at org.drools.common.AbstractRuleBase.addRule(AbstractRuleBase.java:956)
at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:627)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:472)
at
org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)
------------------------------------------------------------------
2. Everytime after 1st failure.
------------------------------------------------------------------
java.lang.NullPointerException
at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:259)
at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:459)
at org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:1107)
at
org.drools.common.AbstractRuleBase.mergePackage(AbstractRuleBase.java:851)
at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:610)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:472)
at
org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)
I have checked numerous times the generated drl (from method toDrl()) is
syntactically correct. The LogMessage has some null fields but they are
checked appropriately in the rules.
I am not sure what is going wrong here. May be the stacktrace provided
above give some pointers to the problem.
Also, please confirm if this is the right way to update rules dynamically.
I have taken a look at KnowledgeAgent but that requires a changeset
represented in XML which I do not have currently in my implementation.
Awaiting response.
11 years, 7 months
Util Method to split "String" content containing declare/end, rule/end, ...
by Charles Moulliard
Hi,
Is there a util method in drools / kie project to split content of a
package that we retrieve using REST from Guvnor ?
package mortgages
// BEGIN
declare LoanApplication
amount: Integer
approved: Boolean
deposit: Integer
approvedRate: Integer
lengthYears: Integer
explanation: String
insuranceCost: Integer
end // SPLIT END HERE
...
rule "CheckBoxDslRule"
dialect "mvel"
when
then
end
Regards,
--
Charles Moulliard
Apache Committer / Sr. Enterprise Architect (RedHat)
Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
11 years, 7 months
Importing Rules as Object into KnowledgeBuilder
by Bojan Janisch
Hello everyone,
is there a way to import Rules as Objects into the Knowledgebase? So far I've seen, Drools supports only Bytearray, Files and InputStream as Rule Resources.
Greetings
Bojan
11 years, 7 months
Fetch Packages using REST api --> KnowledgeBuilder
by Charles Moulliard
Hi,
Using the following code, I can fetch the packages from Guvnor using Rest
API (source) but How can I next create a KnowledgeBuilder based on the
source of Packages retrieved ?
My idea is to use ResourceFactory.
// Fetch Packages from Guvnor
URL url = new URL("
http://127.0.0.1:8080/guvnor.war/rest/packages/mortgages/source");
HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
connection.setRequestProperty("Authorization",
"Basic " + new
Base64().encodeToString(("admin:admin".getBytes())));
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", MediaType.WILDCARD);
connection.connect();
System.out.println("ResponseCode: " + connection.getResponseCode());
System.out.println("MediaType: " + connection.getContentType());
String packages = IOUtils.toString(connection.getInputStream());
InputStream is = connection.getInputStream();
Regards,
--
Charles Moulliard
Apache Committer / Sr. Enterprise Architect (RedHat)
Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
11 years, 7 months
facing problem in KnowledgeAgent
by himansh
Hi,
I am new in guvnor, please help me
my code are bellow
package com.sample;
import org.drools.KnowledgeBase;
import org.drools.RuleBase;
import org.drools.WorkingMemory;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.agent.RuleAgent;
import org.drools.definition.KnowledgePackage;
import org.drools.definition.type.FactType;
import org.drools.runtime.StatefulKnowledgeSession;
@SuppressWarnings("restriction")
public class DroolDemo {
/**
* @param args
* @throws IllegalAccessException
* @throws InstantiationException
*/
public static void main(String[] args) throws
InstantiationException,
IllegalAccessException {
KnowledgeAgent ruleAgent =
KnowledgeAgentFactory.newKnowledgeAgent("/Guvnor.properties");
System.out.println(ruleAgent.getKnowledgeBase().getFactType("org.sample","NumberTest"));
KnowledgeBase ruleBase = ruleAgent.getKnowledgeBase();
System.out.println(ruleBase.getFactType("org.sample","NumberTest"));
FactType factType =
ruleBase.getFactType("org.sample","NumberTest");
Object obj = factType.newInstance();
factType.set(obj, "numberone", 2);
factType.set(obj, "numbertwo", 1);
StatefulKnowledgeSession workingMemory =
ruleBase.newStatefulKnowledgeSession();
workingMemory.insert(obj);
workingMemory.fireAllRules();
System.out.println(factType.get(obj, "message"));
}
}
======================================================
Guvnor.properties:
url=http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/org.sample/testSnapShort2
enableBasicAuthentication=true
username=admin
password=admin
name=drooltest
======================================================
Output:
null
null
Exception in thread "main" java.lang.NullPointerException
at com.sample.DroolDemo.main(DroolDemo.java:34)
======================================================
please help me
thanks,
Him
--
View this message in context: http://drools.46999.n3.nabble.com/facing-problem-in-KnowledgeAgent-tp4023...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 7 months
Open review request for e-book
by Jeremy Ary
Hi all,
I've been given the opportunity to offer a limited number of copies of my
new Instant Drools Starter e-book from Packt Publishing free to interested
parties in return for a blog or consumer review on sellers such as Amazon.
I wanted to offer this to the mailing list community as there are several
loyal members and insightful minds that I'd like to offer to first as a way
of saying thanks for all the help both past and future.
If you're interested, please *EMAIL ME at jeremy.ary(a)gmail.com*. *PLEASE* *DO
NOT reply here in-thread*, as I do not wish to abuse this forum and flood
the list with replies.
More info on book: http://www.packtpub.com/getting-started-with-drools/book
Thanks for your time,
Jeremy Ary
11 years, 7 months
Fusion: Custom Temporal Operators?
by burmanator
Is it possible to create custom temporal operators?
I want to create something like:
$eventA : EventA( this afterStart[3m30s,4m] $eventB)
which would be evaluated as
3m30s <= $eventA.startTimestamp - $eventB.startTimestamp <= 4m
or
$eventA : EventA( this during2 $eventB)
where
$eventB.startTimestamp <= $eventA.startTimestamp<= $eventA.endTimestamp <=
$eventB.endTimestamp
as well as create various others.
--
View this message in context: http://drools.46999.n3.nabble.com/Fusion-Custom-Temporal-Operators-tp4023...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 7 months