[rules-users] Null pointer when retracting Event which has an 'after'

Edson Tirelli ed.tirelli at gmail.com
Mon Nov 16 13:53:23 EST 2009


   Seems like a bug and I did fixed a problem that raised NPE in a similar
situation a few weeks back in trunk. If you can try trunk and let us know if
it still happens, it would be great. Otherwise I will try it myself as soon
as I have a chance.

   Thanks,
      Edson

2009/11/16 richarda <richard.ambridge at gmail.com>

>
> I wish to have a rule that says,  if I get one event, but not another one
> after a period, then do something.
> But I also want to only do this once..
>
> So, I wrote the rules: (using the eclipse sample project)
>
>
>
> declare Message
>        @role( event )
> end
>
> rule "Hello World"
>        when
>                $m : Message( status == Message.HELLO )
>                not ( Message( status== Message.GOODBYE, this after [0s,1m]
> $m)) ;
>        then
>                System.out.println( "Hello" );
> end
>
> rule "GoodBye"
>        when
>                $one : Message( status == Message.HELLO )
>                $two : Message( status == Message.HELLO )
>        then
>                System.out.println( "Two hellos, remove one" );
>                retract($two);
> end
>
>
> But, when I run;
>                        Message message = new Message();
>                        message.setMessage("Hello World");
>                        message.setStatus(Message.HELLO);
>                        ksession.insert(message);
>
>                        Message message2 = new Message();
>                        message2.setMessage("Hello World");
>                        message2.setStatus(Message.HELLO);
>                        ksession.insert(message2);
>                        ksession.fireAllRules();
>
> I get:
> Two hellos, remove one
> java.lang.NullPointerException
>        at
> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:970)
>        at
> org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:885)
>        at
> org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1086)
>        at
>
> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:660)
>        at
>
> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:627)
>        at
>
> org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:183)
>        at com.sample.DroolsTest.main(DroolsTest.java:38)
>
>
> What am i doing wrong?
> --
> View this message in context:
> http://old.nabble.com/Null-pointer-when-retracting-Event-which-has-an-%27after%27-tp26374807p26374807.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091116/ba1741ff/attachment.html 


More information about the rules-users mailing list