Knowledge Agent resource auto loading (.drl/java obj)
by nadeem mehmood
hi friends,
I am working with Knowledge Agent to automatic loading of resources (.drl, .java objects) into the statefullKnowledgeSession KB, and then firing them automatically. The problem is although I have set true the scanDirectories and scanResources configurations of the knowledge agent, but it does't loads the files from the subdirectories.
suppose, if I set in my changeSet.xml as:<add> <resource source='file:src/main/rules/rulerep/' type='DRL' /> </add>
and then put my rules package(including .drl/java objects) it does't loads that.
However if I put the simple drl file with a simple rule like, it loads it and fires also, successfully.rule "Rule 01" when eval (1==1) then System.out.println("Rule 01 Works");end
As we know that we can only reference java objects using packages in rule files. So I want to put a package carrying rules and referenced objects in the focused directory, into which the Knowledge agent is looking for the new resources. in my case it is rulerep.Am new to drools, any suggestions plz.
bst regards,nadeem
15 years
drools-solver NPE in DefaultSimpleScore
by Andrew Waterman
Hi,
I migrated some solver code that I had working on 5.0M4 to the 5.1.0
implementation. I'm now seeing the following while running the solver:
java.lang.NullPointerException
at org.drools.solver.core.score.DefaultSimpleScore.compareTo
(DefaultSimpleScore.java:73)
at org.drools.solver.core.score.DefaultSimpleScore.compareTo
(DefaultSimpleScore.java:13)
at
org.drools.solver.core.localsearch.bestsolution.BestSolutionRecaller.stepTaken
(BestSolutionRecaller.java:56)
at
org.drools.solver.core.localsearch.DefaultLocalSearchSolver.stepTaken
(DefaultLocalSearchSolver.java:171)
at
org.drools.solver.core.localsearch.DefaultLocalSearchSolver.solveImplementation
(DefaultLocalSearchSolver.java:121)
at org.drools.solver.core.AbstractSolver.solve(AbstractSolver.java:41)
I ran my test with a debugger attached, and this call is returning a
Null:
Score bestScore = localSearchSolverScope.getBestScore();
<org.drools.solver.core.localsearch.bestsolution.BestSolutionRecaller:
55>
The BestSolution is not null although the best score is.
Should I file an issue on this in JIRA? Or perhaps this reflects some
change to the old code that I didn't migrate properly?
best wishes,
Andrew
15 years
Mail System Error - Returned Mail
by Returned mail
The original message was received at Fri, 27 Nov 2009 19:03:15 +0100
from lists.jboss.org [15.79.180.224]
----- The following addresses had permanent fatal errors -----
rules-users(a)lists.jboss.org
----- Transcript of the session follows -----
... while talking to 36.211.230.11:
550 5.1.2 <rules-users(a)lists.jboss.org>... Host unknown (Name server: host not found)
15 years
Updates with property change on facts. How???
by Jason Smith
I implemented the following listener for my bean and I am calling .update() directly on the StatefulKnowledgeSession.
QUESTION 1: Is there a better way? The old API supported .insert(fact,boolean). The new one does not. I am not finding any documentation that explains the new API (version 5.0.1).
QUESTION 2: Why is this calling my rule twice? The rule is getting called twice, and the second time it's called, the entry conditions are invalid! That is, I changed the bean in a way that invalidates the WHEN condition. The rule still gets called twice.
How do I even begin to go about troubleshooting this? This same behavior was happening with Drools 4 and the old API as well.
private class InnerPropertyChangeListener implements PropertyChangeListener
{
private final InternalFactHandle factHandle;
private final Object fact;
private final StatefulKnowledgeSession session;
public InnerPropertyChangeListener(InternalFactHandle factHandle, Object fact, StatefulKnowledgeSession session)
{
this.factHandle = factHandle;
this.fact = fact;
this.session = session;
}
@Override
public void propertyChange(PropertyChangeEvent evt)
{
System.out.println("****** UPDATING " + evt.getPropertyName() + ": " +
"\n NEW: " + StringUtil.indent(BeanUtil.printObject(evt.getNewValue()),16) +
"\n OLD: " + StringUtil.indent(BeanUtil.printObject(evt.getOldValue()),16));
if((evt.getNewValue() == null && evt.getOldValue() != null) || !evt.getNewValue().equals(evt.getOldValue()))
{
session.update(factHandle, fact);
}
}
}
Jason Smith
15 years
Timer Node Period not firing repeatedly (running in active mode using fireUntilhalt())
by Boardman, Paul
I 'm using Drools flow 5.1m1 and have created a simple Timer test flow.
It has a simple Action node after the timer that Prints out "Hello".
I have set the timer delay to 5000 and the Timer Period to 2000. What I
expect to happen is I get Hello printed after 5 seconds, then followed
by Hello every 2 seconds until I call halt on the session. However I
just get the first Hello after 5 seconds and that's it.
I am calling session.fireUntilHalt() in a separate thread and then
starting my process just after this thread has started. (basically
copying the code in section 3.9 Timers from the docs)
Thanks
Paul
_______________________________________________________
Atos Origin and Atos Consulting are trading names used by the Atos Origin group. The following trading entities are registered in England and Wales: Atos Origin IT Services UK Limited (registered number 01245534) and Atos Consulting Limited (registered number 04312380). The registered office for each is at 4 Triton Square, Regents Place, London, NW1 3HG.The VAT No. for each is: GB232327983
This e-mail and the documents attached are confidential and intended solely for the addressee, and may contain confidential or privileged information. If you receive this e-mail in error, you are not authorised to copy, disclose, use or retain it. Please notify the sender immediately and delete this email from your systems. As emails may be intercepted, amended or lost, they are not secure. Atos Origin therefore can accept no liability for any errors or their content. Although Atos Origin endeavours to maintain a virus-free network, we do not warrant that this transmission is virus-free and can accept no liability for any damages resulting from any virus transmitted. The risks are deemed to be accepted by everyone who communicates with Atos Origin by email.
_______________________________________________________
15 years
How to enforce dependecy rules
by pdario
Hello,
I need some help to understand how to enforce dependency rules with Drools.
Suppose you have two objects - A and B - and two business rules that say:
"if A is selected, unselect B" and "if B is selected, unselect A".
How can I be sure that Drools unselects B when user selects A and viceversa?
How can avoid a loop or Drools resolving dependency unselecting what the
user just selected?
Should I use Solver or Fusion?
Or... Is Drools the wrong tool?
Thanks a lot!
Dario
--
View this message in context: http://old.nabble.com/How-to-enforce-dependecy-rules-tp26532016p26532016....
Sent from the drools - user mailing list archive at Nabble.com.
15 years
Problems debugging on Eclipse 3.5
by Leonardo Gomes
Hi Guys,
I'm having the following exception while trying to lauch "Debug as Drools
JUnit Test":
FATAL ERROR in native method: JDWP No transports initialized,
jvmtiError=JVMTI_ERROR_INTERNAL(113)
ERROR: transport error 202: connect failed: Connection refused
["transport.c",L41]
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
["debugInit.c",L500]
JDWP exit error JVMTI_ERROR_INTERNAL(113): No transports initialized
I'm using:
* Eclipse 3.5.0
* Drools Eclipse Plugin 5.0.1
* jdk1.5.0_18
Any ideas?
Thank you,
Leo.
15 years
RuleFlow and facts
by paf84
Hello,
I try to understand how to use Drolls.
It's not the first time i work with rules (i know JRules).
I have a probleme when i execute my ruleflow.
I have some rules which belong to different ruleflow-group.
I have put my ruleflow-group in my ruleflow.
THe probleme is that my ruleflow never execute the "then" part of my rules.
If i delete le ruleflow-group of my rules and i execute the drl file, all my
"then" part are executed.
I think i have a problem to give my facts to the ruleflow...
Is somebody can help me ?
thx!!
Pierre
my .java
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
// start a new process instance
System.out.println("init");
Parametre parametre = new Parametre();
parametre.para1 = "para1";
parametre.para2 = "para2";
Parametre parametre2 = new Parametre();
parametre2.para1 = "para1";
parametre2.para2 = "para2";
ksession.insert(parametre);
WorkItemHandler handler = new WorkItemHandler() {
public void executeWorkItem(WorkItem workItem,WorkItemManager manager) {
System.out.println(">" + workItem.getParameters());
System.out.println("Executing work item " + workItem);
manager.completeWorkItem(workItem.getId(), null);
}
public void abortWorkItem(WorkItem workItem,
WorkItemManager manager) {
// Do nothing
}
};
Map<String, Object> parametersDispo = new HashMap<String, Object>();
parametersDispo.put("parametre", parametre);
ksession.getWorkItemManager().registerWorkItemHandler("groupe1",
handler);
ksession.startProcess("com.sample.ruleflow1", parametersDispo);
ksession.fireAllRules();
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample4.drl",
RuleFlowTest.class), ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("ruleFlow1.rf"),
ResourceType.DRF);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
public static class Parametre {
private String para1;
private String para2;
public String getPara1(){
return this.para1;
}
public String getPara2(){
return this.para2;
}
}
One of my rules :
rule "test 1"
ruleflow-group "groupe1"
when
p : Parametre( para1 : para1)
eval (para1 == "para1")
then
System.out.println( "groupe1 test 1" );
end
--
View this message in context: http://old.nabble.com/RuleFlow-and-facts-tp26525341p26525341.html
Sent from the drools - user mailing list archive at Nabble.com.
15 years
Problem with Uploading a Rule File into Guvnor
by ramram8
Hi All
I have the following problem:
When uploading a rule file into Guvnor and this rule file dont contain any
split or join the file is uploaded successfully but once I have uploaded a
rule file with split and join there is an error in the guvnor telling me
unable to generate action invoker.
Please to help in this issue
Below is my rule file:
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process
drools-processes-5.0.xsd"
type="RuleFlow" name="flow" id="com.fp.userTask"
package-name="com.fp" >
<header>
<variables>
<variable name="createUser" >
<type
name="org.drools.process.core.datatype.impl.type.BooleanDataType" />
<value>false</value>
</variable>
<variable name="user" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value></value>
</variable>
<variable name="endProcess" >
<type
name="org.drools.process.core.datatype.impl.type.BooleanDataType" />
<value>true</value>
</variable>
<variable name="index" >
<type
name="org.drools.process.core.datatype.impl.type.IntegerDataType" />
</variable>
</variables>
</header>
<nodes>
<end id="16" name="End" x="586" y="58" width="48" height="48" />
<start id="1" name="Start" x="9" y="160" width="48" height="48" />
<humanTask id="3" name="User Task" x="410" y="58" width="75" height="44"
>
<work name="Human Task" >
<parameter name="ActorId" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>#{user}</value>
</parameter>
<parameter name="Comment" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>This is the SubFlow task #{user} </value>
</parameter>
<parameter name="Content" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>Task after the log process</value>
</parameter>
<parameter name="Priority" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Skippable" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>false</value>
</parameter>
<parameter name="TaskName" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>SubFlow Task</value>
</parameter>
</work>
</humanTask>
<split id="5" name="Gateway" x="329" y="160" width="49" height="49"
type="2" >
<constraints>
<constraint toNodeId="13" name="End Process" priority="2"
type="code" dialect="java" >return endProcess;</constraint>
<constraint toNodeId="3" name="constraint" priority="1" type="code"
dialect="java" >return createUser;</constraint>
</constraints>
</split>
<join id="6" name="Gateway" x="72" y="160" width="49" height="49"
type="2" />
<end id="13" name="End" x="446" y="249" width="48" height="48" />
<workItem id="14" name="Log" x="182" y="163" width="80" height="42" >
<work name="Log" >
<parameter name="Message" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>ReSet the Value of createUser to TRUE</value>
</parameter>
</work>
<mapping type="in" from="index" to="indexParam" />
<mapping type="out" from="createUser" to="createUser" />
<mapping type="out" from="index" to="index" />
<mapping type="out" from="user" to="user" />
</workItem>
<split id="15" name="Gateway" x="517" y="56" width="49" height="49"
type="2" >
<constraints>
<constraint toNodeId="16" name="End Process" priority="2"
type="code" dialect="java" >return endProcess;</constraint>
<constraint toNodeId="6" name="Create New Task" priority="1"
type="code" dialect="java" >return true;</constraint>
</constraints>
</split>
</nodes>
<connections>
<connection from="15" to="16" />
<connection from="5" to="3" />
<connection from="14" to="5" />
<connection from="1" to="6" />
<connection from="15" to="6" bendpoints="[541,30;95,30]" />
<connection from="5" to="13" />
<connection from="6" to="14" />
<connection from="3" to="15" />
</connections>
</process>
--
View this message in context: http://old.nabble.com/Problem-with-Uploading-a-Rule-File-into-Guvnor-tp26...
Sent from the drools - user mailing list archive at Nabble.com.
15 years
Reg: Using window:time(..) method in Guided Editor in Guvnor
by bas karan
Hi,
Can you tell me how window:time(..) function is used in drools guided editor?
I have situation where Collection of objects will be there in entry-point. And if one of the objects matches certain criteria and other other objects match certain criteria, then I have to take do something.
In otherwords, Is it possible to specify "when condition" in guided editor using collection of objects for a given time window from entry-point?
Example condition,
when
remTxnData : REMTxnData(transactionType == "P2P") -- Current object inserted into session
remTxnDataLoad : REMTxnData(remTxnData.accountNumber == accountNumber, transactionType == "CC_LOAD") over window:time(1m) from entry-point TransactionStream
then
--------
end
Thanks
Baskaran S
The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/
15 years