0

次のルールに問題があります。

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

「 eventoGenerico NullPointerException」をリトラクトすると、ワーキングメモリに存在しないかのように発生します(実際に存在し、別のルールで以前に設定eventoGenericoされますtraductor)。

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)

ただし、この小さな変更を加えると、正常に機能します(これにより、eventoGenericoが実際に作業メモリーに存在することが確認されます)。

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

バグのようですが、何かアイデアはありますか?

前もって感謝します

4

2 に答える 2

1

撤回 (traductor) はできますが、Generico にはできません。

問題は、 eventoGenerico が「traductor」ファクトのプロパティであることです。作業メモリ内の事実を参照していないため、撤回することはできません。

別のファクトとして EventoGenerico オブジェクトを挿入しましたが、それを参照したため、それを撤回できるのは 2 番目の (実際の) 例だけです。

于 2013-01-21T13:28:38.573 に答える
1

これは、mvel 方言の使用によって引き起こされた Drools 5.5 のバグのようです。この簡単なテストを使用して、エラーを再現できました。

ジャワ:

Model model = new Model("Model A");
DataSample data = new DataSample(model);
ksession.insert(model);
ksession.insert(data);

ksession.fireAllRules();

よだれ:

rule "Rule 1"
dialect "mvel"
when
    $d: DataSample()
    $m: Model() from $d.model
then
    $d.setModel(null);
    update($d);
    retract($m);
end

方言の "mvel"修飾子を削除すると、ルールは期待どおりに機能します。最近、Drools のメーリング リストに、mvel に関するいくつかのバグ レポートがありました。多分これはそれらの1つです。

よろしくお願いします、

于 2013-01-23T10:04:18.753 に答える