Add two declare ... @role(event) end to listener.drl.
-W
On 11/01/2013, Marco Malziotti <marco.malziotti(a)trs.it> wrote:
Hello
I am a beginner in Drools 5.1.1 and try to listen a event in a packageX
inserted by a rule in another packageY.
I have following 2 drl file :
---inserter.drl----
package packageY
import internal.event.*;
declare EventItem
@role (event)
end
rule "insert EventItem"
when
...
then
EventItem ei = new EventItem(...);
insert(ei);
end
----------------
---listener.drl---
package packageX
import internal.event.*;
rule "listen EventItem temporal constraint"
when
ei: EventItem()
oi: OtherItem(this after ei)
then
System.out.println("Hello word");
end
----------------
EventItem and OtherItem are defined in 'internal.event' package.
If I run with a StatefulKnowledgeSession configured in 'pseudo clock',
I have following stack trace:
java.lang.ClassCastException: org.drools.common.DefaultFactHandle
cannot be cast to org.drools.common.EventFactHandle
at
org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedRight(AfterEvaluatorDefinition.java:322)
at
org.drools.rule.VariableRestriction.isAllowedCachedRight(VariableRestriction.java:117)
at
org.drools.rule.VariableConstraint.isAllowedCachedRight(VariableConstraint.java:121)
at
org.drools.common.SingleBetaConstraints.isAllowedCachedRight(SingleBetaConstraints.java:151)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:125)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:145)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1174)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1123)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:917)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:251)
...
Moving listener.drl in packageY, all works.
I don't know if it is already open a related issue, perhaps the :
https://issues.jboss.org/browse/JBRULES-2774
Thanks for your attention.
Regards.
Marco Malziotti
Tecnologie nelle Reti e nei Sistemi T.R.S. S.p.A.
Integration Test Engineer
Tel. + 39 06.87281.407
Fax. + 39 06.87281.550
E-mail: marco.malziotti(a)trs.it
Tecnologie nelle Reti e nei Sistemi T.R.S. SpA
Via della Bufalotta, 378 - 00139 Roma
Tel +39.06.87.28.1.1 - Fax +39.06.87.28.1.550
-------------------------------------------------------
Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni contenute in
questo messaggio
sono riservate ed a uso esclusivo del destinatario. Qualora il messaggio in
parola Le
fosse pervenuto per errore, la preghiamo di eliminarlo senza copiarlo e di
non inoltrarlo
a terzi, dandocene gentilmente comunicazione. Grazie.
This message, for the law 196/2003, may contain confidential and/or
privileged information.
If you are not the addressee or authorized to receive this for the
addressee, you must not
use, copy, disclose or take any action based on this message or any
information herein.
If you have received this message in error, please advise the sender
immediately by reply
e-mail and delete this message. Thank you for your cooperation.
-------------------------------------------------------
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users