Migrating from 4.0.7 to 5.4.0.Final
by JP Chemali
Hi all,
I'm currently in the process of migrating an application using drools 4.0.7
to 5.4.0.Final and I've stumbled into a few issues with the new version that
I find disturbing:
- Our unit tests failed because the JVM ran out of perm gen space, which
looks odd as in 4.0.7 we've had quite a margin to start with.
- Doing several Yourkit analysis, I finally find classloading leaks:
* *org.drools.rule.builder.dialect.asm.ClassGenerator.EMPTY_METHOD_BODY*
is a static instance which will hold to the last instance of
InternalClassLoader created
* *org.drools.rule.constraint.MvelConstraint* uses an ExecutorHolder that
spawns daemon threads and keeps them in a pool. Problem is these threads
create class loaders, and can only be garbage collected when the thread
dies, meaning never in my case...
- I've quick fixed both issues, the second one by simply disabling the
thread pool.
- Once this is done, the perm gen behaves correctly, but the execution times
are 2-3 times slower on very large set of rules (~1000). Looking at Yourkit
analysis again, I see that the number of classes generated and the perm gen
consumption is about 3 times higher in 5.4.0.Final. I honestly don't know
how to address this.
I've tried to find some other posts concerning these issues, to no avail. I
don't see any work around this, short of code changes, and for reducing the
number of generated classes I simply have no idea.
Please correct me if I am wrong, any help would be greatly appreciated
--
View this message in context: http://drools.46999.n3.nabble.com/Migrating-from-4-0-7-to-5-4-0-Final-tp4...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Inserting Facts from Json Format
by ihabo01
Hello to all,
I have the following simple rule:
declare FlatData
param1 : String
param2 : String
end
rule "Test"
when
a:FlatData(param1=="something")
then
a.setParam2("hi");
end
And I have the following code to load the rule:
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add(ResourceFactory.newFileResource("myRule.drl"),ResourceType.DRL);
KnowledgeBaseConfiguration kBaseConfig = KnowledgeBaseFactory
.newKnowledgeBaseConfiguration();
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(kBaseConfig);
kBase.addKnowledgePackages(kBuilder.getKnowledgePackages());
StatefulKnowledgeSession session = kBase.newStatefulKnowledgeSession();
session.fireAllRules();
And I have also the following object (in Json) that I would like to insert
as a fact just before firing the rules:
{"object":{" FlatData ":{"param1":"value1","param2":”value2”}}}}
How can I achieve that?
Many thanks in advance for your help
Ihab
--
View this message in context: http://drools.46999.n3.nabble.com/Inserting-Facts-from-Json-Format-tp3570...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Performance issue
by Ini
Hi All,
I have written a code to check the properties of a bean using drools based
rules.
I have created the different rules file where different properties of the
bean will be checked.
The code i have written is a as below:
public static void check(Object details,String rule){
long methodStartTime=System.currentTimeMillis();
Resource resource = new ClassPathResource(RULE_CLASSPATH+rule);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
long startTime=System.currentTimeMillis();
kbuilder.add(resource, ResourceType.DRL );
long endTime=System.currentTimeMillis();
System.out.println("Time taken in add resource in milli seconds
is::"+(endTime-startTime));
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
}
StatelessKnowledgeSession ksession =
kbase.newStatelessKnowledgeSession();
ksession.execute(details);
long methodEndTime=System.currentTimeMillis();
System.out.println("Time taken in Method check in milli seconds
is::"+(methodEndTime-methodStartTime));
}
Here in the check method we have three parameters details this is the bean
whose properties need to be checked in rules file, rule this is the name of
rules file which contains all the rules.
Here the issue is that it takes around 4 seconds for the first time and 1
second for all consecutive requests, and 4 second looks too much time for
validating the rules file that has only 10 rules.
Please let me know we have some better way of doing it in drools
--
View this message in context: http://drools.46999.n3.nabble.com/Performance-issue-tp4017688.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Guvnor Help !!
by abhinay_agarwal
Hey,
I’ve been using GUVNOR for uploading JARS and creating rules using FACTS..
Now I thing I wanna know is - a rule which is GLOBAL AREA, can it be used
to fire rules which are there in some different package ?? (same facts may
be uploaded in both GLOBAL AREA and the PACKAGE !! .. if requirement asks
for it !!! )
Thanks,
Abhinay
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-Help-tp4018290.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Possibly Broken drools-core-5.4.0.Final.jar?
by Darin Wilcox
Hello all,
I have an application that was written originally using Drools 5.3.1.Final
that works just fine. I wrote a JUnit test that runs through values
contained in a spreadsheet. Everything was working great. I updated the
application to use Drools 5.4.0.Final and then the test stopped working. I
have debugged the code and here is the exception thrown:
Exception executing consequence for rule "create vcmax" in
org.zoikks.drools: java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1283)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1209)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1442)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at
org.zoikks.drools.xlsx.SampleWorkflowXlsx.check(SampleWorkflowXlsx.java:103)
at
org.zoikks.drools.xlsx.SampleWorkflowXlsx.testSampleXlsxSheets(SampleWorkflowXlsx.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NullPointerException
at ConditionEvaluator0f64b1c63942476d80eb29d1cdffda28.evaluate(Unknown
Source)
at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:167)
at
org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:124)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
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:337)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:888)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:187)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:181)
at
org.zoikks.drools.Rule_create_vcmax_692832fd6e0547e09b6f632175df45ff.defaultConsequence(Rule_create_vcmax_692832fd6e0547e09b6f632175df45ff.java:7)
at
org.zoikks.drools.Rule_create_vcmax_692832fd6e0547e09b6f632175df45ffDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
org.zoikks.drools.Rule_create_vcmax_692832fd6e0547e09b6f632175df45ffDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1273)
... 26 more
This appears to be a race-condition occurring someplace within the app
because it executes find some times, yet other times a NPE is thrown. The
location where the exception is originating is new to Drools 5.4.0.Final so
there is nothing to compare against in previous versions. Has anyone else
seen this and/or does anyone know how to solve this problem?
I have attached code that is using Drools 5.4.0.Final. To successfully
re-produce the problem, place a breakpoint at
org.drools.rule.constraint.MvelConstraint.evaluate() [Line 167] and then
step through. The exception has been occurring continuously.
Thanks,
- Darin
13 years, 8 months
ruleflow-group
by al so
looks like one can't activate a ruleflow-group inside a drl file? Only
available via UI?
I was thinking there'll be some kind of setFocus way to control rule
execution using this ruleflow-group.
13 years, 8 months
KnowledgeAgent custom class loader not working for PKG resources
by Hrumph
I believe there may be a bug when trying to use a custom class loader with
the KnowledgeAgent and the KnowledgeBuilderConfiguration, and when the
ChangeSet is a PKG resource.
I have been trying to get the knowledge-agent-classloader sample from the
new Drools Cookbook to work with a PKG resource. The sample works fine for
a DRL resource, but when I convert it to use my fact jar, and a PKG resource
containing my rules, which I downloaded from Guvnor, it throws a
ClassNotFoundException for my fact model. If I put my fact model in the
classpath, the error goes away and my rules can be added to the
KnowledgeAgent and run correctly. Following is the code from the sample
that I have converted, and I have attached a zip file with a complete
project demonstrating the problem. Also, I can get my rules and fact
model to work if I use a DRL ChangeSet.knowledge-agent-classloader.zip
URL modelJarURL = getClass().getResource("Patient-1.0.jar");
URLClassLoader customURLClassloader = new URLClassLoader(new URL[]
{modelJarURL });
KnowledgeBuilderConfiguration kbuilderConfig =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null,
customURLClassloader);
KnowledgeBaseConfiguration kbaseConfig =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null,
customURLClassloader);
KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig);
KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("test", kbase, aconf,
kbuilderConfig);
// kagent.applyChangeSet(new ClassPathResource("change-set.xml",
getClass())); // this goes with model.jar
// kagent.applyChangeSet(new ClassPathResource("drl-change-set.xml",
getClass())); // this goes with Patient.jar
kagent.applyChangeSet(new ClassPathResource("pkg-change-set.xml",
getClass())); // this goes with Patient.jar
return kagent.getKnowledgeBase();
Following is the stack trace from the error:
java.lang.NullPointerException
at
org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:148)
at
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1016)
at
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:785)
at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:657)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:190)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:169)
at
drools.cookbook.chapter02.KnowledgeAgentClassloaderTest.createKnowledgeBase(KnowledgeAgentClassloaderTest.java:59)
at
drools.cookbook.chapter02.KnowledgeAgentClassloaderTest.customClassloaderTest(KnowledgeAgentClassloaderTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at
org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at
org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
I have been having the exact same problem when trying to use a custom class
loader with just a KnowldegeBuilder and no KnowledgeAgent.
http://drools.46999.n3.nabble.com/file/n3746456/knowledge-agent-classload...
knowledge-agent-classloader.zip
--
View this message in context: http://drools.46999.n3.nabble.com/KnowledgeAgent-custom-class-loader-not-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
GUVNOR 5.4 JBOSS v4.2.3 deployment error
by abhinay_agarwal
hey,
i was trying to upgrade from guvnor 5.3.0 to 5.4 when i pasted the guvnor
war into the deployment folder and restarted the server it throwed an error
2012-06-29 10:06:52,163 DEBUG [org.jboss.web.WebModule] Starting failed
jboss.web.deployment:war=drools-guvnor.war,id=-1487681113
org.jboss.deployment.DeploymentException: Error during deploy; - nested
throwable: (javax.naming.NamingException: resource-env-ref: BeanManager has
no valid JNDI binding. Check the jboss-web/resource-env-ref.)
i know its some binding error in jboss but any help would be appreciated !!
Thanks in advance,
Abhinay
--
View this message in context: http://drools.46999.n3.nabble.com/GUVNOR-5-4-JBOSS-v4-2-3-deployment-erro...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months