[rules-users] Exception executing consequence for rule xxx in yyy: java.lang.RuntimeException: unable to access field

Mario Fusco mario.fusco at gmail.com
Thu Jan 17 03:09:04 EST 2013


Thank you Wolfgang,

your bug report is crystal clear as usual ;)
I'll try to reproduce and fix this asap.

Mario

On Thu, Jan 17, 2013 at 7:29 AM, Wolfgang Laun <wolfgang.laun at gmail.com>wrote:

> The error occurs when the following rule fires ;-)
>
> rule "error occurs"
>    $fact1: Fact( $class: class )
>    $fact2: Fact( class == $class, this != $fact1 )
>    Field( $name: name, type == $class, modifiers == Modifier.PUBLIC )
>    Rule( dialect == "mvel",
>             $rule: name
>             rightHandSide matches (".\\s*" + $name + "\\s*=\\s*\S+\\s*;" )
> );
> then
>    System.out.println( "When rule " + $rule + " fires, an exception
> occurs" );
> end
>
> In words:
> All the following conditions must be met:
>    * WM contains at least two facts of the same type
>    * there is a public field
>    * the rule's dialect is set to MVEL
>    * a rule's right hand side contains an assignment to the public field
>
> Occurs with versions 5.[2345].0
>
> -W
>
>
> On 16/01/2013, Chang Liu <CLiu at deltadentalmi.com> wrote:
> > A rule to repro this situation:
> >
> > The rule:
> > ...
> > rule "Assignment In Action Test"
> >     when
> >       obj : Foo()
> >     then
> >       obj.x = 1;
> >         System.out.println("Rule Fired!");
> > end
> > ...
> >
> > Definition of class Foo:
> > public class Foo {
> >       public int x;
> >       public int getX() {
> >               return x;
> >       }
> >       public void setX(int x) {
> >               this.x = x;
> >       }
> > }
> >
> > Objects been inserted:
> > Foo foo1 = new Foo();
> > foo1.x = 0;
> > Foo foo2 = new Foo();
> > Foo2.x = 1000;
> >
> > Note that if only one Foo object is inserted, things work fine. If more
> than
> > one Foo objects are inserted, we see this Exception:
> >
> > Exception executing consequence for rule "Assignment In Action Test" in
> > com.sample: java.lang.RuntimeException: unable to access field
> >       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
> >
> com.sample.AssignmentInActionTestMain.main(AssignmentInActionTestMain.java:37)
> > Caused by: java.lang.RuntimeException: unable to access field
> >       at
> >
> org.mvel2.optimizers.impl.refl.nodes.DynamicFieldAccessor.setValue(DynamicFieldAccessor.java:66)
> >       at
> >
> org.mvel2.optimizers.impl.refl.nodes.IndexedVariableAccessor.setValue(IndexedVariableAccessor.java:43)
> >       at
> >
> org.mvel2.compiler.CompiledAccExpression.setValue(CompiledAccExpression.java:59)
> >       at
> >
> org.mvel2.ast.DeepAssignmentNode.getReducedValueAccelerated(DeepAssignmentNode.java:92)
> >       at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
> >       at
> >
> org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:126)
> >       at org.mvel2.MVEL.executeExpression(MVEL.java:930)
> >       at
> org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:101)
> >       at
> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1273)
> >       ... 6 more
> > Caused by: java.lang.NullPointerException
> >       at org.mvel2.DataConversion.convert(DataConversion.java:118)
> >       at
> >
> org.mvel2.optimizers.impl.refl.nodes.DynamicFieldAccessor.setValue(DynamicFieldAccessor.java:61)
> >       ... 14 more
> >
> > -----Original Message-----
> > From: rules-users-bounces at lists.jboss.org
> > [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Wolfgang Laun
> > Sent: Wednesday, January 16, 2013 10:35 AM
> > To: Rules Users List
> > Subject: Re: [rules-users] Exception executing consequence for rule xxx
> in
> > yyy: java.lang.RuntimeException: unable to access field
> >
> > What's the type of $billingOutputRuleContext.retroPreviousBillAmount?
> >
> > On 16/01/2013, magaram <magaram at deltadentalmi.com> wrote:
> >> The behavior stated seems very erratic as other similar rules are
> >> executing.
> >> Also note that the fields in the consequence have a visibility of
> public.
> >> Are there any known issues surrounding this?
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >> http://drools.46999.n3.nabble.com/Exception-executing-consequence-for-
> >> rule-xxx-in-yyy-java-lang-RuntimeException-unable-to-access-field-tp40
> >> 21553p4021576.html Sent from the Drools: User forum mailing list
> >> archive at Nabble.com.
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> > **********************************************************************
> > CONFIDENTIALITY NOTICE: The information contained in this email is
> intended
> > only for the person or entity to which it is addressed and may contain
> > confidential and/or privileged material. If you are not the intended
> > recipient, you are hereby notified that any unauthorized review, use,
> > dissemination, distribution or copying of this communication is
> prohibited
> > and may be subject to legal restriction or sanction. If you have received
> > this email in error, please notify the sender immediately to arrange for
> > return or destruction of the information and all copies. If you are the
> > intended recipient but do not wish to receive communications through this
> > medium, please advise the sender immediately. Thank you
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130117/3925c693/attachment.html 


More information about the rules-users mailing list