Drools and StatefulKnowledgeSession performance
by Peter Troelsen
Hi,
I have implemented a small amount (around a 100) rules. Then I made some
performance tests for my implementation to see how fast my implementation
is. However I have noticed a tends whenever running tests for a long time.
It seems that every time i insert an object, validate it, and then remove
it from the ksession using .retract(t), the following insertion gets
slower and slower. This doesn't really show in the beginning, but after the
first couple of million objects, i really starts to escalate..
Have anyone noticed the same kind of thing? I am positive the i retract *all
*my objects after validating, but still, it seems to get slower. Is the any
way to do an extra clean, without retracting the rules or do I simply need
to reinitialize the ksession occasionally?
Thanks in advance!
--
Peter Troelsen
10 years, 11 months
Drools 5.5 java.lang.ClassCastException: org.drools.compiler.rule.builder.dialect.mvel.MVELDialectConfiguration cannot be cast to org.drools.compiler.DialectConfiguration
by anjana.ackroyd
I am stuck with this error
java.lang.ClassCastException:
org.drools.compiler.rule.builder.dialect.mvel.MVELDialectConfiguration
cannot be cast to org.drools.compiler.DialectConfiguration
I am using Intellij IDE. I have googled the error and tried all options but
nothing seems to work
Here is my pom dependencies
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.5.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.5.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>5.5.0.Final</version>
</dependency>
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
<version>2.0.10</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>2.5.16</version>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.drools</artifactId>
<version>5.1.1_1</version>
</dependency>
Here is my Code
//I added the Properties after reading that someone solved the problem using
those lines
private KnowledgeBase readKnowledgeBase() throws Exception {
Properties props = new Properties();
props.setProperty("drools.dialect.java.compiler", "JANINO");
KnowledgeBuilderConfiguration config =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(props, null);
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(config);
kbuilder.add(ResourceFactory.newUrlResource("http://vlslcitcat07.abc.com:38083/guvnor/org.drools.guvnor.Guvnor/package..."),
ResourceType.CHANGE_SET);
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;
here is my DRL file in Guvnor
rule "numberone is equals to numbertwo"
when
n: NumberCompare(numberone == numbertwo);
then
n.setMessage("numberone is equals to numbertwo");
end
rule "numberone is greater than numbertwo"
when
n: NumberCompare(numberone > numbertwo);
then
n.setMessage("numberone is greater than numbertwo");
end
rule "numberone is less than numbertwo"
when
n: NumberCompare(numberone < numbertwo);
then
n.setMessage("numberone is less than numbertwo");
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-5-5-java-lang-ClassCastException...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Using a DRL file on Guvnor/Workbench while using Drools Camel Server
by jordan.brown
So far in my attempts, I am unable to use a DRL file that exists on Drools
Workbench/Guvnor while using Drools Integration with Apache Camel. I would
like to be able to use a rule file that can be managed from the UI, along
with KIE scanner, monitoring the maven repository for changes. I'm sourcing
from the JAR coming from the remote repository of Guvnor, where the DRL
lies, but it's not picking it up in the server so far in my testing.
I have the Drools Camel Server up sending messages and executing rules
against the knowledge session, but as of right now, the DRL file is created
locally.
I'm not seeing anything on the documentation concerning my question.
--
View this message in context: http://drools.46999.n3.nabble.com/Using-a-DRL-file-on-Guvnor-Workbench-wh...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Drools 5.5.0 - Runtime Exception java.lang.RuntimeException: Provider org.drools.agent.impl.KnowledgeAgentProviderImpl could not be set
by anjana.ackroyd
Here is my snippet of my code in 5.5.0.Final
import org.drools.KnowledgeBase;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.definition.type.FactType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatelessKnowledgeSession;
KnowledgeAgent ka = KnowledgeAgentFactory.newKnowledgeAgent("MyAgent");
ka.applyChangeSet(
ResourceFactory.newClassPathResource("src/main/resources/ChangeSet.xml") );
KnowledgeBase kb = ka.getKnowledgeBase();
FactType factType =
kb.getFactType("org.numbercompare","NumberCompare");
Object nc = factType.newInstance();
factType.set( nc, "numberone",numberone );
factType.set( nc, "numbertwo", numbertwo );
StatelessKnowledgeSession ks = kb.newStatelessKnowledgeSession();
ks.execute(nc);
I get the following error
java.lang.RuntimeException: Provider
org.drools.agent.impl.KnowledgeAgentProviderImpl could not be set
Here are my dependencies in pom.xml
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.5.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.5.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>5.5.0.Final</version>
</dependency>
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-5-5-0-Runtime-Exception-java-lan...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
How to push changes to cloned repo on Kie-Workbench
by anjana.ackroyd
I was able to do all my steps successfully on the work bench , Cloned my
repository, added a new project, package,drl file, build and deployed it.
I see wb created the repositories on my local machine which is good but I
dont see a way to push those changes to my cloned reposity
Git Push?
I am not even sure what branch of the cloned repository the work bench is
using
I noticed on this URL below there is recommendation to use the
./kie-config-cli.sh script to push changes
http://docs.jboss.org/drools/release/6.0.0.Final/drools-docs/html/wb.Work...
I downloaded the zip file from
https://github.com/droolsjbpm/kie-wb-distributions/tree/6.0.x
Ran the script from \kie-config-cli\src\main\dist but I get a error message
Exception in thread "main" java.lang.NoClassDefFoundError:
org/kie/config/cli/CmdMain
Caused by: java.lang.ClassNotFoundException: org.kie.config.cli.CmdMain
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.kie.config.cli.CmdMain. Program will
exit.
I was hoping there would be a way to push my changes from the Workbench UI
itself.
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-push-changes-to-cloned-repo-on-K...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Null pointer when inserting data (5.5.0.Final)
by Anders Henriksson
Hi!
We're running drools in a multi-server setup, with a pretty basic scenario:
1. When the first session is needed, we load the rulebase once. The rulebase is never changed after this (no rule removal or addition).
2. Each call spawns a new StatefulKnowledgeSession which is used for firing the rules once and then disposed. These calls are heavily multi-threaded, but each session is only used in a single method call from a single thread.
3. We use the resource scanner to check for updated packages. When an updated knowledge package is available, the knowledgebase is discarded and a new one constructed from the updated package.
The knowledge package affected is somewhat large - about 25 MB in size. (There are other, smaller knowledge packages which do not appear to have this issue.)
This setup has been working fine, but somewhat slow. After upgrading to 5.5.0.Final and adding some speedups in the surrounding code we get a spurious null pointer. The trail of events is:
1. After start all servers work fine.
2. Sometime after a couple of hours to a couple of days, the null pointer error occurs on one or more servers (but generally not all of them).
3. Once the null pointer occurs, it happens on all further calls using that knowledgebase. No other knowledgebases are effected. (You can load the same package in a new knowledgebase, and sessions using the new, identical, knowledgebase work just fine.)
4. Restarting the java process makes the server work fine again.
Calls always fail with the same stack trace:
org.drools.RuntimeDroolsException: Unexpected exception executing action org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction@5db53f
24
at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:995)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:335)
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)
<stacktrace from our calling code omitted>
Caused by: java.lang.NullPointerException
at org.drools.rule.EvalCondition.createContext(EvalCondition.java:107)
at org.drools.reteoo.EvalConditionNode.createMemory(EvalConditionNode.java:261)
at org.drools.common.ConcurrentNodeMemories.createNodeMemory(ConcurrentNodeMemories.java:90)
at org.drools.common.ConcurrentNodeMemories.getNodeMemory(ConcurrentNodeMemories.java:69)
at org.drools.common.AbstractWorkingMemory.getNodeMemory(AbstractWorkingMemory.java:1034)
at org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:174)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:196)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:145)
at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:154)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.reteoo.Rete.assertObject(Rete.java:109)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:286)
at org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:434)
at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:993)
... 93 more
Unfortunately we don't have the remaining rows in the wrapped exception.
>From this trace, it looks like the problem is in EvalCondition:
public Object createContext() {
return this.expression.createContext();
}
which should only be able to produce a null pointer if expression is missing. Looking at the constructors for this class, having a null expression seems like a valid use case - but if this is a valid use case, why doesn't createContext() handle this case?
Considering that running drools with the same package and the same inputs can either fail with the above error (if knowledgebase has been used enough) or work just as intended (using a newly minted knowledgebase), it feels like something is corrupting the knowledgebase. Does this make sense?
(I noticed in the issue tracker ( https://issues.jboss.org/browse/DROOLS-156 ) that memory for eval nodes are 'created "too lazily"' - might this be a related issue?)
Best regards,
Anders
10 years, 11 months
Sending Java Objects Through Camel, received by Drools 6
by jordan.brown
Hi,
We're currently testing sending XML/JSON (including a message and drools
commands) through Camel and Drools receiving it (using the documentation
given--Part IV Drools Integration in the Doc), but we're curious if it's
possible to just send a Java Object (e.g., Person Object) through Camel and
have Drools pick it up--whereby the object will be received by drools and
then the actual insert and firing of rules will occur on the other side
(i.e., we wouldn't send the drools commands to Camel).
Out-of-the-box, is this possible? Anybody doing this? As of now, we're
continuing the approach in the Drools documentation (Part IV Drools
Integration).
-Jordan
--
View this message in context: http://drools.46999.n3.nabble.com/Sending-Java-Objects-Through-Camel-rece...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Drools6 : Having trouble in using kie-ci
by vimalkansal
Hi,
I have an instance of Kie-WB running and I have started it with property
"org.guvnor.m2repo.dir" set to some non default location (i.e not in
/../home/.2). I am able to use the KIE WB to "build and deploy" the project
to this repository. Then I have built a web application ( I have declared
the dependency on org.kie/kie-ci module and I have verified that this jar is
getting packaged under WEB-INF/lib folder of my .war file). So with this
setup, when I have a code like this in my web application :
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = null;
*kContainer = ks.newKieContainer(ks.newReleaseId("com.xyz", "HelloWorld",
"1.0.0-SNAPSHOT"));*
it seems to wait inordinately long at the highlighted line and then throws
up an exception to the telling can't get the default Kie Session. My
question :
Do I have to tell the web application about the location of the maven
repo? if yes how?
Thx
Vimal
--
View this message in context: http://drools.46999.n3.nabble.com/Drools6-Having-trouble-in-using-kie-ci-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months