Declarative fact model or Java?
by Stephen Masters
Hi folks,
I quite like the clean separation provided by maintaining a declarative fact model rather than a Java model. In particular to me, it seems to make it easier to manage rules in Guvnor separate from my runtime environment. However I can also see how maintaining a Java model simplifies some activities, avoiding having to map between and external Java model and an internal representation, and making it easy to modify facts from within a knowledge session.
Is there anybody out there who has experience doing a number of projects both ways, and has developed an opinion on whether one is preferable the other? Or is there perhaps more of a decision tree pertaining to which is better in particular situations?
And on a side-note, is there anything out there that helps with mapping between Java beans and declarative facts? I was wondering about hacking up some AOP aspects to enable me to annotate a Java model in a slightly JPA/ORM style to help with mapping/marshalling between the two.
Thanks for any thoughts.
Steve
stephen.masters(a)me.com
14 years, 3 months
Fusion historical data analysis
by MartinSimo
Dear drools Users
I'd like to evaluate drools for our next project, thus a newbie.
Trying to write a rule, which hits, if a threshold is reached 3 times in 100
seconds.
having:
kpi1 -- representing the timestamp of the event (as data are read from DB)
and kpi2 where the actual value is.
having rule:
...
@expires( 200s )
@timestamp( kpi1 )
...
$arrayList : ArrayList( size > 3) from collect(
LogEntry ( $kpi2 : kpi2 > 0.10) over window:time( 100s ) )
I have a test set of kpi2 20x each 5s over 0.1 and then 50x each 5s below
0.1.
The first time the rule hits its correct (after the first 3 ticks kpi2>0.1)
but it continues to hit till the end of the test set, even if the 100s
window didn't have any>0.1.
As I understood the @expires should have wiped the old data out of the
working mem. (tried to set @expire( 2s), but with same result)
Do I miss something?
Deployed in Jboss 5.1.0ga ESB 4.10, drools 5.2.0)
any help is appreciated
Martin
--
View this message in context: http://drools.46999.n3.nabble.com/Fusion-historical-data-analysis-tp36735...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
FireAllRules for all agenda
by Vis
Hi,
We are having huge set of rules categoried into different agends, based on
different functional behavior.
And session.fireAllRule works fine with respect to an agend.
But there is one more scenario where we need to fire all the rules
irrespective of any agenda group, even main agend also.
1. Does Drools provide any such API call like fireAllRules where all rules
can be fired irrespective of agenda?
2. If not, what is work around?
Thanks in adavance.
Thanks,
V
--
View this message in context: http://drools.46999.n3.nabble.com/FireAllRules-for-all-agenda-tp3674638p3...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Can we set a default value for emlpty cells in Drools templates
by swaroop
Hi,
I am trying to write a template and came across a scenario where one of the
condition cell $a : Company(condition), When
condition is left blank then entire predicate is missed and iam using the
ref of the company obj $a to set some values which is failing as the
declaration part is missing, So i was thinking, if we can have a default
value to the cell as $a : Company(), then the scenario will be
handled.Kindly let me know how to implement the default value for a cell in
template to overcome the above mentioned scenario
Thanks
Swaroop
--
View this message in context: http://drools.46999.n3.nabble.com/Can-we-set-a-default-value-for-emlpty-c...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
ClassCastException when KnowledgeAgent loads declared type
by lhorton
Code level: 5.2.0.Final
I have a DRL file that includes a declared type:
package com.abclegal.rules.servicerequirements
declare TransgressionMetaData
attempt : ServiceAttempt
requirement : Requirement
end
The package loads the first time and its rules run without error. If I make
a change to the file and hot-deploy it (copy it to the server), the
ResourceChangeScanner picks up the file and KnowledgeAgent loads it, but
when any rule from that package subsequently fires, I get a
ClassCastException on the declared type:
com.abclegal.rules.servicerequirements.TransgressionMetaData cannot be cast
to com.abclegal.rules.servicerequirements.TransgressionMetaData
it appears the KnowledgeAgent is not replacing the existing (in working
memory) definition of the declared type, but instead is creating a new one
with a different hash code.
looks like a bug?
Full stack trace:
Caused by: RulesConsequenceException executing consequence for rule
"PHOTO_WHEN_SERVED: Photo must be taken if served." in
com.abclegal.rules.servicerequirements
[Error: drools.insert(new TransgressionMetaData($attempt,$req)):
com.abclegal.rules.servicerequirements.TransgressionMetaData cannot be cast
to com.abclegal.rules.servicerequirements.TransgressionMetaData]
[Near : {... @Modify with($attempt){ ....}]
^
[Line: 1, Column: 1]
java.lang.ClassCastException:
com.abclegal.rules.servicerequirements.TransgressionMetaData cannot be cast
to com.abclegal.rules.servicerequirements.TransgressionMetaData
Rules working memory:
Fact ServiceAttempt id: 17
at
com.abclegal.rules.utility.RulesConsequenceExceptionHandler.handleException(RulesConsequenceExceptionHandler.java:24)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:912)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:845)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1056)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:733)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at
org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:305)
at
com.abclegal.rules.server.RulesServiceImpl.execute(RulesServiceImpl.java:378)
... 44 more
Caused by: [Error: drools.insert(new TransgressionMetaData($attempt,$req)):
com.abclegal.rules.servicerequirements.TransgressionMetaData cannot be cast
to com.abclegal.rules.servicerequirements.TransgressionMetaData]
[Near : {... @Modify with($attempt){ ....}]
^
[Line: 1, Column: 1]
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:409)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:140)
at
org.mvel2.optimizers.dynamic.DynamicOptimizer.optimizeAccessor(DynamicOptimizer.java:67)
at org.mvel2.ast.ASTNode.optimize(ASTNode.java:154)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:110)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:86)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:122)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:115)
at org.mvel2.MVEL.executeExpression(MVEL.java:928)
at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:105)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:906)
... 51 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:1066)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:338)
... 61 more
--
View this message in context: http://drools.46999.n3.nabble.com/ClassCastException-when-KnowledgeAgent-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Upgrade Drools from 5.1 to 5.3
by womuji
Hi,
We have a legacy Drools application using 5.1 and we are planning to upgrade
to 5.3. I have several questions:
1. Are org.drools.StatelessSession and RuleBase deprecated? and instead we
should use KnowledgeBase and StatelessKnowledgeSession?
2. In 5.1.1, we extend WorkingMemoryLogger(final WorkingMemoryEventManager
workingMemoryEventManager) , but it's changed to WorkingMemoryLogger(final
WorkingMemory workingMemory) in 5.3, how do we change accordingly?
Thanks in advance.
--
View this message in context: http://drools.46999.n3.nabble.com/Upgrade-Drools-from-5-1-to-5-3-tp367287...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Groovy classes as fact classes in drool
by kavita
Hi,
Can anybody tell me how to use groovy classes as fact classes in drools.
When i try to upload the jar file generated from the groovy class am getting
the following error:
SEVERE: Servlet.service() for servlet AssetFileServlet threw exception
java.lang.ClassNotFoundException: groovy.lang.GroovyObject
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at
org.drools.rule.MapBackedClassLoader.loadClass(MapBackedClassLoader.java:109)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at
org.drools.rule.MapBackedClassLoader.fastFindClass(MapBackedClassLoader.java:86)
at
org.drools.rule.MapBackedClassLoader.loadClass(MapBackedClassLoader.java:104)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
org.drools.guvnor.server.contenthandler.ModelContentHandler.isClassVisible(ModelContentHandler.java:183)
at
org.drools.guvnor.server.contenthandler.ModelContentHandler.getImportsFromJar(ModelContentHandler.java:148)
at
org.drools.guvnor.server.contenthandler.ModelContentHandler.onAttachmentAdded(ModelContentHandler.java:66)
at
org.drools.guvnor.server.files.FileManagerUtils.attachFileToAsset(FileManagerUtils.java:115)
at
org.drools.guvnor.server.files.FileManagerUtils.attachFile(FileManagerUtils.java:87)
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.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:163)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at
org.drools.guvnor.server.files.FileManagerUtils_$$_javassist_seam_10.attachFile(FileManagerUtils_$$_javassist_seam_10.java)
at
org.drools.guvnor.server.files.AssetFileServlet.processAttachFileToAsset(AssetFileServlet.java:97)
at
org.drools.guvnor.server.files.AssetFileServlet.doPost(AssetFileServlet.java:49)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
at
org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:65)
at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Please help.
Thanks,
Kavitha.
--
View this message in context: http://drools.46999.n3.nabble.com/Groovy-classes-as-fact-classes-in-drool...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months