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?
14 years
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
14 years
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.
14 years
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)
14 years
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.
14 years
Drools Salience and no-loop
by gboro54
So I have setup my drools execution as follows:
1.A single thread is pooling Orders from the db and insert them into X
number of sessions(10) running on separate threads(fireUntilHalt()).
2. I have a set up rules which need to execute first to allow other rules
to fire so I have rules such as:
rule "main 1"
salience 1000
no-loop true
when
<some_conditions>
then
<modify order info>(update is invoked)
end
3. There is another set of rules which then check the Order for these
preconditions along with others
rule "sub 1"
salience 100
no-loop true
when
<some_conditions>
<main 1 consequences present>
then
<modify order info>(no update invoked as other rules in the
session don't care)
end
4. I then have a single rule which has a low salience and should be last
rule to fire in the activation which retracts the Order and hands it to a
service for post processsing
rule "END"
salience -100
no-loop true
when
ord:Order
then
retract(ord);
invokeService(ord);
end
The problem I am having is that my END rule is being invoked on certain
Orders in working memory before the other activation have taken any affect(I
have verified this by send a replicated order 1000 times and each time a
large majority his the service before anything was modified on the order).
Am I missing something?
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Salience-and-no-loop-tp3812723p3...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Re: [rules-users] Using 'in' operator to find objects inside a list
by FrankVhh
As documented:
Use 'memberOf' instead of 'in'.
Regards,
Frank
purna wrote
>
> drl file looks like this..
> global ArrayList<Long> accountNumberBlackList
> .
> .
> .
> rule blackListToCheck
> when
> "$transaction : Transaction(accountTo.number in
> (accountNumberBlackList))"
>
> then
> $transaction.setStatus(Transaction.Status.DENIED);
> //.. do something else?
> end
>
> I want to use 'in' operator to find numbers that are stored in global
> variable accountNumberBlackList.
> Is the above syntax(in double quotes) correct?
> is there any alternative to look inside a list?
>
--
View this message in context: http://drools.46999.n3.nabble.com/Using-in-operator-to-find-objects-insid...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
(no subject)
by Christabelle Galea
g.christabelle(a)gmail.com
14 years
java.lang.ArrayIndexOutOfBoundsException thrown in mvel2's compiler when running drools5.3 final.
by Miles Wen
hi all,
the exception below is usually thrown when the system is busy(usually 9-10
am everyday);
The rules runs perfectly when unit test or any other time when the system
is not very busy(like 22:00 - 4:00 every day);
Our system processes 13000000 pieces of data each day, with
4-5 java.lang.ArrayIndexOutOfBoundsException thrown on average.It's not
very often but doubtful.
The logs are shown below:
2012-03-07 10:10:33,683 [] ERROR ruleservice.RuleServiceImpl - Error
occurred while invoking business filter!
java.lang.reflect.InvocationTargetException
at
com.alibaba.china.avatar.offer.rulematch.OfferMatchFilter$$FastClassByCGLIB$$18f6f037.invoke(<generated>)
at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
at
com.alibaba.china.ruleservice.RuleServiceImpl.bindParamAndInvoke(RuleServiceImpl.java:264)
at
com.alibaba.china.ruleservice.RuleServiceImpl.match(RuleServiceImpl.java:82)
at sun.reflect.GeneratedMethodAccessor248.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at
com.alibaba.china.avatar.interceptor.KeyDataLoggingAfterThrowingInterceptor.invoke(KeyDataLoggingAfterThrowingInterceptor.java:24)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
com.alibaba.dragoon.patrol.spring.DragoonMethodInterceptor.invoke(DragoonMethodInterceptor.java:106)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy16.match(Unknown Source)
at
com.alibaba.china.avatar.offer.decode.OfferMessageAction.run(OfferMessageAction.java:39)
at
com.alibaba.china.rialto.core.module.DefaultActionModule.doWork(DefaultActionModule.java:375)
at
com.alibaba.china.rialto.core.module.DefaultActionModule.runModule(DefaultActionModule.java:252)
at
com.alibaba.china.rialto.core.module.ModuleRunner.run(ModuleRunner.java:31)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.drools.RuntimeDroolsException: Exception executing predicate
Helper.containsAny(offerSubject, ((Set)colMap.get("_set_212")))
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:298)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:458)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:386)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:845)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:255)
at
com.alibaba.china.ruleservice.session.impl.drools5.TransientDrools5Session.insertFact(TransientDrools5Session.java:100)
at
com.alibaba.china.avatar.offer.rulematch.OfferMatchFilter.doFilter(OfferMatchFilter.java:57)
... 23 more
Caused by: [Error: unexpected end of statement]
[Near : {... Helper.containsAny(offerSubject,
((Set)colMap.get("_set_212"))) ....}]
^
[Line: 1, Column: 39]
at org.mvel2.compiler.AbstractParser.nextToken(AbstractParser.java:1215)
at
org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:128)
at org.mvel2.util.ParseTools.subCompileExpression(ParseTools.java:2090)
at org.mvel2.ast.Substatement.<init>(Substatement.java:37)
at org.mvel2.compiler.AbstractParser.nextToken(AbstractParser.java:1062)
at
org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:128)
at org.mvel2.util.ParseTools.subCompileExpression(ParseTools.java:2079)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:953)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:375)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:141)
at org.mvel2.ast.ASTNode.optimize(ASTNode.java:157)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:113)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:87)
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:930)
at
org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:100)
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:291)
... 35 more
Caused by: java.lang.ArrayIndexOutOfBoundsException
I looks like there's some issue in mvel2's parser.The problem occurs when
dynamic compiling mvel2 code.
And every ArrayIndexOutOfBoundsException is thrown around here:
'Helper.containsAny(offerSubject, ((Set)colMap.get("_set_212")))' .This is
a custom static function call which implements come sort of operation not
supported by drools5.
Is this a bug about mvel2?Or any one encountered this problem also? How
could I avoid it?
Thnaks!
--
Regards.
Miles. Wen
14 years