how to use dynamic drl file in drools 6
by merry0900
drools 6 has a great advance from drools5.
I am a begginer of both drools 5 and drools6.
My question is that I don't know how to impliment dynamic drl which means
my drl(rule) file may change during the running of my app since in drools 6
target a drl file like this:
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/kie/6.0.0/kmodule">
<kbase name="HelloWorldKB" packages="org.drools.examples.helloworld">
<ksession name="HelloWorldKS"/>
</kbase>
....................
this file is located in src/main/resources/META-INF/kmodule.xml.
And then the drl file will be packaged in the jar file.
when i want to change my drl file, how can i do. note:i don't want to
rebuild my java source to jar.
for any help? thank you all, from china.
--
View this message in context: http://drools.46999.n3.nabble.com/how-to-use-dynamic-drl-file-in-drools-6...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Drools 6 MBeans not getting listed in Oracle JConsole
by Rupesh M G
Hi,
JConsole (of Oracle JDK 1.7) is not listing the drools expert 6 mbeans.
I tried the following Drools 6 sample KieContainerFromKieRepoExample.
I set the JVM option -Ddrools.mbeans=enabled, but JConsole did not list the mbeans.
When I tried the same in a Drools 5.5 sample, the mbeans were listed in JConsole.
Is it a bug in Drools expert 6? Or did I miss any required step for 6? Please help.
public void go(PrintStream out) {
KieServices ks = KieServices.Factory.get();
// Install example1 in the local maven repo before to do this
KieContainer kContainer = ks.newKieContainer(ks.newReleaseId("org.drools", "named-kiesession", "6.0.0-SNAPSHOT"));
KieSession kSession = kContainer.newKieSession("ksession1");
kSession.setGlobal("out", out);
Object msg1 = createMessage(kContainer, "Dave", "Hello, HAL. Do you read me, HAL?");
kSession.insert(msg1);
kSession.fireAllRules();
}
Thanks & Regards,
Rupesh
DISCLAIMER: "The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."
12 years
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
12 years
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.
12 years
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.
12 years
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.
12 years
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.
12 years
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
12 years