Unable to initialize KieBase from Windows file system
by Daniel Straub
We try try to initialize a KieBase like this:
but no rule files where found.
Spending some time for debugging, we realized that in KieBuilderImpl (and
other places) file names are compared with linux path delimiter
but - as usally known - Windows file system uses '\' .
We made the followin hack in
org.drools.compiler.commons.jci.readers.DiskResourceReader :
and everything runs.
Please respect that some people have to use windows (unfortunatly ...)
--
View this message in context: http://drools.46999.n3.nabble.com/Unable-to-initialize-KieBase-from-Windo...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
External storage and timers
by didierC
Hi,
We want to use the external storage API for our Fusion project (Drools 6.0 -
beta2).
We have temporal based rules and when we load an existing session, we get:
...
Caused by: java.lang.NullPointerException
at
org.drools.core.common.Scheduler$ActivationTimerInputMarshaller.deserialize(Scheduler.java:238)
at
org.drools.core.marshalling.impl.ProtobufInputMarshaller.readTimer(ProtobufInputMarshaller.java:627)
at
org.drools.core.marshalling.impl.ProtobufInputMarshaller.readSession(ProtobufInputMarshaller.java:282)
at
org.drools.core.marshalling.impl.ProtobufInputMarshaller.readSession(ProtobufInputMarshaller.java:154)
at
org.drools.core.marshalling.impl.ProtobufMarshaller.unmarshall(ProtobufMarshaller.java:114)
at
org.drools.core.marshalling.impl.ProtobufMarshaller.unmarshall(ProtobufMarshaller.java:56)
at
org.drools.persistence.SessionMarshallingHelper.loadSnapshot(SessionMarshallingHelper.java:83)
... 35 more
I can reproduce the problem in a simple test case:
public class TestStorage {
private SimpleKnowledgeSessionStorage storage;
@Before
public void initStorage() {
storage = new SimpleKnowledgeSessionStorage();
}
@Test
public void testStorageWithTimer() throws InterruptedException {
KieSession session = getSession(null);
int id = session.getId();
String rule = "package test\n";
rule += "import erdf.poc.cep.*;\n";
rule += "rule \"test\"\n";
rule += "timer (cron:0/2 * * * * ?)\n";
rule += "when\n";
rule += "then\n";
rule += "insert(\"test\"+System.currentTimeMillis());\n";
rule += "end";
addRule(session, rule);
session.fireAllRules();
Thread.sleep(2000);
session.fireAllRules();
final int facts = session.getFactHandles().size();
Assert.assertTrue(facts>=1);
session.dispose();
Thread.sleep(2000);
session = getSession(id);
addRule(session, rule);
session.fireAllRules();
Assert.assertTrue(session.getFactHandles().size()>facts);
session.dispose();
}
private KieSession getSession(Integer i) {
final Environment env = KnowledgeBaseFactory.newEnvironment();
EnvironmentBuilder envBuilder = new
KnowledgeSessionStorageEnvironmentBuilder(storage);
env.set(EnvironmentName.TRANSACTION_MANAGER,
envBuilder.getTransactionManager());
env.set(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER,
envBuilder.getPersistenceContextManager());
KieStoreServices storeS = KieServices.Factory.get().getStoreServices();
final KieBase kieBase = KnowledgeBaseFactory.newKnowledgeBase();
if (i != null) {
return storeS.loadKieSession(i, kieBase, null, env);
}
return storeS.newKieSession(kieBase, null, env);
}
private static class SimpleKnowledgeSessionStorage implements
KnowledgeSessionStorage {
public Map<Integer, SessionInfo> ksessions = new HashMap<Integer,
SessionInfo>();
public Map<Long, WorkItemInfo> workItems = new HashMap<Long,
WorkItemInfo>();
public SessionInfo findSessionInfo(Integer id) {
return ksessions.get(id);
}
public void saveOrUpdate(SessionInfo storedObject) {
ksessions.put(storedObject.getId(), storedObject);
}
public void saveOrUpdate(WorkItemInfo workItemInfo) {
workItems.put(workItemInfo.getId(), workItemInfo);
}
public Long getNextWorkItemId() {
return new Long(workItems.size() + 1);
}
public WorkItemInfo findWorkItemInfo(Long id) {
return workItems.get(id);
}
public void remove(WorkItemInfo workItemInfo) {
workItems.remove(workItemInfo.getId());
}
public Integer getNextStatefulKnowledgeSessionId() {
return ksessions.size() + 1;
}
}
}
Any idea ?
Thanks for your help
Didier
--
View this message in context: http://drools.46999.n3.nabble.com/External-storage-and-timers-tp4024486.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
Memory-Problemwith instance of "ReteooStatefulSession"
by anniejoseph
Hi,
I'm using jBoss Rules.But I run in to memory issues after using JBoss
rules. Using a profiling tool I collected heap dump
and I got the result as :
/One instance of "org.drools.reteoo.ReteooStatefulSession" loaded by
"sun.misc.Launcher$AppClassLoader @ 0x7f899fdb6d88" occupies 657,328,888
(78.91%) bytes.
The memory is accumulated in one instance of
*"org.drools.reteoo.ReteooStatefulSession"*
loaded by "sun.misc.Launcher$AppClassLoader @ 0x7f899fdb6d88".
Keywords
sun.misc.Launcher$AppClassLoader @ 0x7f899fdb6d88
org.drools.reteoo.ReteooStatefulSession/
The code I used for JBoss rules is given below.
kbase= KnowledgeBaseFactory.newKnowledgeBase();
ksession= kbase.newStatefulKnowledgeSession();
final String str =
CISMSRemotingUtils.getFullConfigFilePath("change-set.xml") ;
final String filePath = str.replaceAll(" ", "%20");
aconf = KnowledgeAgentFactory .newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.newInstance", "false");
kagent = KnowledgeAgentFactory.newKnowledgeAgent( "Agent", aconf);
kagent.applyChangeSet( ResourceFactory.newFileResource(filePath) );
kbase = kagent.getKnowledgeBase();
ksession= kbase.newStatefulKnowledgeSession();
sconf
=ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty( "drools.resource.scanner.interval", "3600");
ResourceFactory.getResourceChangeScannerService().configure( sconf );
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
This piece of code is given in the class constructor and rules are fired
inside this class
ksession.insert(data);
ksession.fireAllRules();
Can anyone help me to identify the problem?
--
View this message in context: http://drools.46999.n3.nabble.com/Memory-Problemwith-instance-of-ReteooSt...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
No eval with backward chaining?
by Wolfgang Laun
Trying to use eval in a query for backward chaining causes a runtime
crash running Drools 5.5.0. Looks like a bug. The details:
Given some Integer objects as facts,
rule "find triple forward"
when
Integer( $a: intValue )
Integer( $b: intValue > $a )
Integer( $c: intValue > $b )
eval( $a*$a + $b*$b == $c*$c )
then
System.out.println( "fwd: " + $a + " " + $b + " " + $c );
end
finds Pythagorean triples.
But
query isTriple( Integer $a, Integer $b, Integer $c )
Integer( intValue == $a )
Integer( intValue == $b && > $a )
Integer( intValue == $c && > $b )
eval( $a*$a + $b*$b == $c*$c )
end
intended to be used in combination with
rule "find triple backward"
when
isTriple( $a, $b, $c; )
then
System.out.println( "bwd: " + $a + " " + $b + " " + $c );
end
causes a nasty runtime error (although DRL compilation succeeds):
Exception in thread "main" java.lang.NoSuchMethodError:
pythagoras.Rule_isTriple_17ac16f7237046ee9562afce35dfe174.eval0(III)Z
at pythagoras.Rule_isTriple_17ac16f7237046ee9562afce35dfe174Eval0InvokerGenerated.evaluate(Unknown
Source)
at pythagoras.Rule_isTriple_17ac16f7237046ee9562afce35dfe174Eval0Invoker.evaluate(Unknown
Source)
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:114)
at org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:176)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:196)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:71)
at org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:159)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
at pythagoras.Main.makeFacts(Main.java:94)
at pythagoras.Main.execute(Main.java:78)
at pythagoras.Main.main(Main.java:103)
-W
11 years, 6 months
sharing functions across namespaces
by Jeremy Ary
Anyone know of an elegant solution to sharing functions across packages?
As an example, given a single DRL containing all of functions:
package com.rules
and two rules files who both use those functions, yet live in separate
namespaces:
package com.rules.setOne
package com.rules.setTwo
Can both namespaces utilize the functions without changing all of my
rules files to the namespace com.rules? If worth noting, only one of
the namespaces will be present in the kbase at a time.
Thanks,
Jeremy
11 years, 6 months
drools 6 and osgi
by Florian.Pirchner
hi,
i got a question about osgi support.
is beta 3 already useable in osgi environments? could see that activators are registering v5 api as services.
is it possible to consume osgi services in the script tasks and rules by context? is this planned for version 6? would be a great feature.
thanks a lot for answer
florian
11 years, 6 months
Fire Rule in Stateless Knowledge Session
by snehils
Hi,
I am new in Drools. I am using Drools version 5.1.0
My requirement is kind of request response, where I have to perform some
checks for the request and respond the result. Hence, I decided to go with
stateless knowledge session.
I have prepared .DRL file and it contains set of rules. When some request
receives I have to identify the rule(s) belongs to that request and then
fire the rule(s).
I am not able to figure out how to categories the rules request wise in DRL
file? Also, how to fire only those rules which belongs to the category.
For example, there are three kinds of requests Rq1, Rq2 and Rq3. There are
rules in DRL file: R1, R2, R3, R4 and R5. R1, R2 belongs to Rq1, R3 belongs
to Rq2 and R4, R5 belongs to Rq3.
When some request receives only its belonging rules should be fired. For
example, on receiving of Rq2 only R3 should be fired.
Please provide me some code snipped or link.
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Fire-Rule-in-Stateless-Knowledge-Sessio...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
Question : Camel + kie-spring (Drools6)
by Charles Moulliard
Hi,
I have some problems to understand the new way to create with Drools 6 a
knowledge base, kession.
For a kie-camel project by example we must use the following syntax :
<kie:ksession-ref id="ksession1">
<kie:batch>
<kie:set-global identifier="list" >
<bean class="java.util.ArrayList" />
</kie:set-global>
</kie:batch>
</kie:ksession-ref>
Question : How kbase and kcontainer are created in this case ?
So, why can't we use this one ?
<kie:kbase-ref id="drl_sample"/>
<kie:ksession id="kession1" kbase-ref="drl_sample"/>
Question : How kbase links info retrieved from kmodules ?
Hope that documentation will clarify that ?
Regards,
--
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
11 years, 6 months