I´ve got a problem with the following rule:
rule "Término sin Traducción"
salience -100
dialect "mvel"
when
traductor : TraductorDeEventosTratados()
eventoGenerico : EventoGenerico() from traductor.eventoGenerico
then
System.out.println("Evento generico: " + eventoGenerico);
traductor.setEventoGenerico( null );
update( traductor );
retract( eventoGenerico );
end
It causes a NullPointerException when retracting the “eventoGenerico”, as though it doesn’t exist in the working memory (it exists actually, and another rule sets the eventoGenerico to traductor previously):
Exception executing consequence for rule "Término sin Traducción" in RULA_PROV.SYSTEM_RULES: [Error: drools.retract( eventoGenerico ): null]
[Near : {... System.out.println("Evento gen ....}]
^
[Line: 1, Column: 1]
at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
However, if I make this little change it works fine (this verifies that the eventoGenerico really exists in the working memory):
rule "Término sin Traducción"
salience -100
dialect "mvel"
when
traductor : TraductorDeEventosTratados()
eventoGenerico : EventoGenerico()
eventoGenerico2 : EventoGenerico( this == eventoGenerico ) from traductor.eventoGenerico
then
System.out.println("Evento generico: " + eventoGenerico);
traductor.setEventoGenerico( null );
update( traductor );
retract( eventoGenerico );
end
It looks like a bug, any ideas?
Thanks in advance
This appears to be a bug in Drools 5.5 caused by the usage of mvel dialect. I managed to reproduce your error using this simple test:
Java:
Drools:
If you remove the dialect “mvel” modifier, the rule works as expected. Recently in Drools’ mailing list there were some bug reports regarding mvel. Maybe this is one of them.
Best Regards,