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.
12 years, 4 months
rule execution flow..
by al so
Given a rule definition file(.drl), Is there any UI tool that can visualize
the execution order of Rules? [based on the controls (salience,etc) defined
inside the rule]
12 years, 4 months
ConcurrentModificationException loading facts from db (Hibernate).
by groovenarula
In my use case, I have ~ 200,000 rows in a table that I need lookup in order
to price an item. Rather than load the entire table into working memory,I'm
trying load the relevant rows (based on a matching criteria) and load those
as facts and then have my rules evaluate the loaded facts. Based on that
I've got the following rule :
rule "Load pricelist"
salience 10000
when
$priceUnit : PriceUnit()
not ( exists Pricelist( id.prodid == $priceUnit.prodid ) )
$unitPrices : ArrayList() from collect ( Pricelist() from
PricelistUtilities.getPriceLists($priceUnit.prodid) )
then
for( Pricelist priceList : (List<Pricelist>) $unitPrices ) {
insert (priceList);
}
end
In the rule above - 'PriceUnit' is the unit that I'm trying to price. And
'Pricelist' is the facts that I'm trying to fetch from a table based on the
prodid matching and inserting those into WM. The
PricelistUtilities.getPriceList returns a list of price list items that
match the 'Product id' (prodid). In the RHS, all I'm trying to iterate over
the list of pricelists and then insert those into WM.
When I execute the rule above, I can see that the rule is executing the
'select' to load pricelists :
Hibernate:
/*
from
PriceList
where
status = 'A'
and end_date >= current_date
and prodid = '010366'
and cover_grade = 'LF' */ select
pricelist0_.prodid as prodid1_,
pricelist0_.cover_grade as cover2_1_,
pricelist0_.cover_series as cover3_1_,
pricelist0_.cover_color as cover4_1_,
pricelist0_.division as division1_,
pricelist0_.location as location1_,
pricelist0_.list as list1_,
pricelist0_.start_date as start8_1_,
pricelist0_.end_date as end9_1_,
pricelist0_.timestamp as timestamp1_,
pricelist0_.status as status1_,
pricelist0_.sold_flag as sold12_1_,
pricelist0_.base_price as base13_1_,
pricelist0_.list_price as list14_1_,
pricelist0_.add_on as add15_1_,
pricelist0_.landed_frt as landed16_1_
from
catalog.pricelist pricelist0_
where
pricelist0_.status='A'
and end_date>=current_date
and prodid='123456'
However, I get an java.util.ConcurrentModificationException when the rule
fires :
org.drools.runtime.rule.ConsequenceException: rule: Load pricelist
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:737)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:701)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at com.generic.rules.utils.DroolsTest.main(DroolsTest.java:46)
Caused by: java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at
com.sample.Rule_Load_pricelist_0.defaultConsequence(Rule_Load_pricelist_0.java:7)
at
com.sample.Rule_Load_pricelist_0DefaultConsequenceInvoker.evaluate(Rule_Load_pricelist_0DefaultConsequenceInvoker.java:27)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
... 6 more
If I comment the check for existing PriceList Items 'not ( exists Pricelist(
id.prodid == $priceUnit.prodid ) )', then it works fine. But as soon as I
add the check back, it breaks.
Is this a bug or am I doing something wrong ?
Any help / insight will be appreciated.
Thanks in advance.
--
View this message in context: http://drools.46999.n3.nabble.com/ConcurrentModificationException-loading...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
eval call from java code
by rogelio_sevilla1
Good day everyone:
Sorry if this is a too basic question.
I'm having a recurrent problem on my rules and I still don't know how to
really solve it, I searched here at the forum but I'm not so sure that the
solutions proposed would work for my use case.
I have to call many different methods on the LHS of some of my rules so I
insert a global 'utils' object and I make my calls within eval() blocks,
like this:
$myObj1: ClassX (eval(globalUtil.reSupplyNeeded(amount) ))
Everything works fine for now. I wrapped all my util methods within try
catch blocks to avoid screwing up my stateful session (in my use case, is
CRITICAL to keep the session alive). So, if an exception is thrown, I return
false or true depending on the method.
My main problem is with evals where I do comparisons like this one:
eval($myObj1.doSomething()==$myObj2.doSomething())
I have many of these and some times I get an annoying NPE. I know I could
add !=null comparisons but my rules would grow considerably. eval is
extremely useful so I was wondering if I can call it from my utility class,
something like this:
On my Drl file:
rule "eval called from here and utility class"
when
$someObj1 : ClassX()
$someObj2 : ClassY()
$myObj : Class1( eval(
globalUtil.doEval($someObj1.doSomething()==$someObj2.doSomething() ) ) )
then
...bla bla bla
end
On my Utility Class
public boolean doEval(ClassIDontKnow argument){
try{
//I don't know if this even exists, just asking if it's possible
return Drools.eval(argument);
}
catch(Exception e){
logger.error("Something bad happened!!");
return false;
}
}
Is something like this even possible?? , if not, other approach that you
would recommend me??
Thanks a lot in advance :-)
--
View this message in context: http://drools.46999.n3.nabble.com/eval-call-from-java-code-tp4018398.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 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.
12 years, 4 months
Globals - delegate
by Wolfgang Laun
This is from Expert (5.4.0):
Using a delegate is another way of global resolution. Assigning a
value to a global (with setGlobal(String, Object)) results in the
value being stored in an internal collection mapping identifiers to
values. Identifiers in this internal collection will have priority
over any supplied delegate. Only if an identifier cannot be found in
this internal collection, the delegate global (if any) will be used.
For setting a delegate, I've found org.drools.runtime.Globals and
void Globals.setDelegate(Globals delegate)
and the KnowledgeRuntime /StatelessKnowledgeSession method
Globals getGlobals()
Does this mean that one might take a Globals object from one session
and use it as a delegate to the Globals of another session?
(Evil thought:
Globals a = sessionA.getGlobals();
Globals b = sessionB.getGlobals();
a.setDelegate( b );
b.setDelegate( a );
What happens then?)
-W
12 years, 4 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.
12 years, 4 months