Class test fails (!= same as ==)
by Wolfgang Laun
Using 5.3.0.Final, arbitrary facts and the rule shown below:
import org.drools.reteoo.InitialFactImpl
rule "Clear" when
$f: Object() #######
then
if( ! ($f instanceof InitialFactImpl) ){
System.out.println( "retract a " + $f.getClass() );
retract( $f );
}
end
This retracts my Foo, Bar and Counter facts. Good.
$f: Object( class == Foo.class ) ####### changed
This retracts all of my Foo facts. Excellent.
$f: Object( class != Foo.class ) ####### changed again
This retracts only Foo facts. Bad.
-W
12 years, 9 months
MVEL and nested properties takes longer time to build working memory
by Anto Paul
Hi,
I have rules that uses nested properties. There are more than thousands
of such rules. Before using any nested properties, time to build working
memory(from decision tables) was pretty fast. After using nested
properties, rule compilation time increased by many folds and it is worse
in environments where NAS is used instead of SCSI disks.
Worst thing is I am not able to profile app using VisualVM as it gives
error that 64k limit of instrumented methods exceeded. So took some thread
dump using jstack and see that most often thread is doing class loading.
This is performed by MVEL classes.
On seeing this I used custom class loader in KnowledgeBuilder and
printed all loaded classes. I do not see that MVEL is using custom class
loader and is directly reading class using some other class loader.This
class loading is taking pretty long time when using network disks.
Is there any way to speed up rule compilation time when using nested
properties.Is there anything like a hint to tell MVEL to load fields of an
object directly from that class instead of searching it in entire
classpath? I see something like "m:" in
MVELDialectRuntimeData.getParserConfiguration().
Using Drools 5.30 Final and Decision tables.
Thanks,
Anto
12 years, 9 months
matches operator
by shawn
Hey there.
I get stuck on using matches operator. The Documentation doesn't say the
operator in details.
I just need to find whether String2 contains String1 (Ignore Case).
Now I have a key(String variable) and a value(String variable).
If I write key matches value, I know it definitely wrong. So is there anyone
knows how to write it?
Cheers.
Shawn
--
View this message in context: http://drools.46999.n3.nabble.com/matches-operator-tp3816492p3816492.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Having problems with traits in 5.4.0beta2
by Greg Barton
I'm trying out the traits feature and I'm having some problems. I'm preparing simple Monkeys and Bananas example with existing classes that I want to add traits, but when I try adding a trait (either declared in DRL or as a static interface) I'm getting an exception thrown from the call to don(). Here's the code:
declare HungryMonkey
@format(trait)
end
rule "foo"
when
monkey : Monkey( )
then
HungryMonkey hm = don(monkey, HungryMonkey.class);
end
And the exception thrown:
Exception in thread "main" Exception executing consequence for rule "foo" in org.gregcode.mnb: org.drools.RuntimeDroolsException: Field/method 'attachment' not found for class 'org.gregcode.mnb.MonkeyWrapper'
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:709)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:673)
at org.gregcode.mnb.Main.main(Main.java:49)
Caused by: org.drools.RuntimeDroolsException: Field/method 'attachment' not found for class 'org.gregcode.mnb.MonkeyWrapper'
at org.drools.base.ClassFieldAccessorFactory.getClassFieldWriter(ClassFieldAccessorFactory.java:199)
at org.drools.base.ClassFieldAccessorCache$CacheEntry.getWriteAccessor(ClassFieldAccessorCache.java:187)
at org.drools.base.ClassFieldAccessorCache.getWriteAcessor(ClassFieldAccessorCache.java:116)
at org.drools.base.ClassFieldAccessorStore.wire(ClassFieldAccessorStore.java:424)
at org.drools.base.ClassFieldAccessorStore.getAccessor(ClassFieldAccessorStore.java:216)
at org.drools.factmodel.traits.TraitFactory.buildWrapperClassDefinition(TraitFactory.java:340)
at org.drools.factmodel.traits.TraitFactory.getCoreWrapper(TraitFactory.java:310)
at org.drools.base.DefaultKnowledgeHelper.don(DefaultKnowledgeHelper.java:493)
at org.drools.base.DefaultKnowledgeHelper.don(DefaultKnowledgeHelper.java:522)
at org.gregcode.mnb.Rule_foo_3c2199da53c4480ea0ec7b3d1c4781b5.defaultConsequence(Rule_foo_3c2199da53c4480ea0ec7b3d1c4781b5.java:7)
at org.gregcode.mnb.Rule_foo_3c2199da53c4480ea0ec7b3d1c4781b5DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
at org.gregcode.mnb.Rule_foo_3c2199da53c4480ea0ec7b3d1c4781b5DefaultConsequenceInvoker.evaluate(Unknown Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
"MonkeyWrapper" is not in my code, so I'm assuming it's generated. I also tried creating a HungryMonkey and HungryMonkeyImpl interface/class pair like the Scholar and ScholarImpl from the traits example, but the same exception happened. Any clues?
12 years, 9 months
Adhoc NullPointer exception in rule execution
by Zhuo Li
Hi, folks,
I'm using Drools 5.1, MVEL dialect, JDK 1.6 to build a OLTP system running
on tomcat 6.0.28. the runtime environment is on a cloud virtual and node
profile is relatively small. We've noticed below run time exceptions from
prod since it's online from day one which is impacting transaction
processing. However it is happening adhoc-ly. Here I have 1 question:
1. The yellow marked lines are actually java file compiled from DRL
file. Why there is null pointer exception thrown from
org.drools.common.DefaultAgenda.fireActivation?
ERROR>2012-02-25 11:42:25,071
com.xxx.xxx.xxx.xxx[DefaultQuartzScheduler_Worker-3]: Rules run time error:
org.drools.runtime.rule.ConsequenceException: rule: Match
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleExcept
ion(DefaultConsequenceExceptionHandler.java:39)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:916)
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.j
ava:733)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.j
ava:699)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeS
essionImpl.java:218)
at com. xxx.xxx.xxx.xxx.xxx.xxx.xxx (SessionManager.java:94)
at com. xxx.xxx.xxx.xxx.xxx.xxx.yyy(SessionManagerJob.java:17)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525
)
Caused by: java.lang.NullPointerException
at com.xxx.xxx.xxx.xxx.xxx.xxx.xxx(xxx.java:634)
at com.xxx.xxx.xxx.xxx.xxx.yyy.yyy(yyy.java:227)
at com.xxx.xxx.xxx.xxx.xxx.yyy.zzz(zzz.java:115)
at com.xxx.xxx.xxx.xxx.xxx.yyy.ttt(ttt.java:83)
at com.xxx.xxx.xxx.xxx.xxx.yyy.uuu(uuu.java:75)
at com. com.xxx.xxx.xxx.xxx.xxx.yyy.vvv(vvv.java:9)
at com. com.xxx.xxx.xxx.xxx.xxx.yyy.www(www.java:28)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:906)
... 9 more
Best regards
Abe
12 years, 9 months
Duration attritube and Temporal Operators
by mind
Hello everybody,
I recently started using Drools (with C#) and I have some problems in
understanding how temporal operators work with the duration field. According
to the documentation, the temporal operators work with startTimestamp and
endTimestamp of events, the semantics being defined with inequalities. In
order to work, temporal operator requires the duration field to be declared.
Now the questions:
1. What does @timeStamp stay for? The start or the end timestamp?
2. Does Drools calculate startTimestamp and endTimestamp if I set @timeStamp
and @duration attribute from my C# code? If not how can I set them? (like
shall I declare like @startTimeStamp(sth) and set from the C# code?)
3. Do temporal operators work if I do not set explicitly the start and end
timestamps but just @timeStamp and @duration attributes?
In particular, I have this drl file (%VAR% are replaced by other code):
declare IntensionalEvent
@role(event)
@timeStamp(timeStamp)
@duration(duration)
end
rule "Expression (%EVENTNAME1%, %OPERATOR%, %EVENTNAME2%, %TIMESPAN%,
%TIMEVAR%)"
dialect "mvel"
when
$eventA : IntensionalEvent( name == '%EVENTNAME2%' )
$eventB : IntensionalEvent( this %OPERATOR% $eventA,
name == '%EVENTNAME1%'
) over window:time( %TIMESPAN% )
then
blah blah... create an IntensionalEvent and set timestamp
and duration
end
Thanks everybody,
Gil
--
View this message in context: http://drools.46999.n3.nabble.com/Duration-attritube-and-Temporal-Operato...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
java.lang.NoClassDefFoundError in rule execution
by Zhuo Li
Hi, folks,
I'm using Drools 5.1, JDK 1.6 on tomcat 6.0.28 to build a OLTP application.
System's volume is about 1.5 million transactions a day. The pilot PROD
release was done about 1 week ago and we've noticed many
NoClassDefFoundError exception run time. A sample piece is pasted below. For
information security concern, I masked class names here. This happened much
more frequent when system load pressure is big - memory is between 80% to
100% and disk is between 80% - 100%. As we are running on a cloud virtual
instance environment, virtual node has relatively small profile - 40GB disk,
4GB memory, 2 core Intel 3.0 GHz CPU. I've searched through the web and
found some reported bug -
https://issues.jboss.org/browse/JBRULES-2253?_sscc=t. here I got two
questions:
1. If anybody in the community has met similar issue before and how
you fix it?
2. It seems I can either convert my rule into Java Dialect or turn off
MVEL2 JIT attribute: Dmvel2.disable.jit=true. Does anybody have summary
information about the good and bad between MVEL and JAVA dialect?
ERROR>2012-03-09 10:00:22,432
com.xxx.xxx.xxx.drools.SessionManager[pool-5-thread-6]: Unexpected error :
java.lang.NoClassDefFoundError: com/xxx/xxx/xxx/xxx/xxx/GetAmountTolerance
at ASMAccessorImpl_20916505061331280591040.getValue(Unknown Source)
at
org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue(DynamicGetAccessor.
java:73)
at
org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:110)
at
org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.jav
a:124)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:89)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:125)
at org.mvel2.MVEL.executeExpression(MVEL.java:928)
at
org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpressio
n.java:101)
at
org.drools.rule.PredicateConstraint.isAllowedCachedLeft(PredicateConstraint.
java:314)
at
org.drools.common.DefaultBetaConstraints.isAllowedCachedLeft(DefaultBetaCons
traints.java:226)
at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:98)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(Sing
leLeftTupleSinkAdapter.java:197)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTup
le(SingleLeftTupleSinkAdapter.java:146)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.jav
a:154)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObject
SinkAdapter.java:59)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObject
SinkAdapter.java:59)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(Composi
teObjectSinkAdapter.java:450)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(Composite
ObjectSinkAdapter.java:368)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:193)
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:191)
at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:332)
at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:293)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:90
5)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:86
4)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSession
Impl.java:255)
at
com.ssc.gce.reconcile.drools.SessionManager.insert(SessionManager.java:116)
at
com.ssc.gce.reconcile.drools.SessionManager.run(SessionManager.java:171)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
va:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9
08)
at java.lang.Thread.run(Thread.java:662)
12 years, 9 months
How to include one .drl file from another .drl file
by Shur, Bob
Is there something like #include for drl files? That is, something like this:
rule "1"
when
then
doSomething;
end
#include "another.drl"
rule "2"
when
...
I know I can load multiple drl files into the knowledge base in Java. I'm just wondering whether someone writing a drl file can include other drls without having to copy and paste.
12 years, 9 months