<br> Christoph,<br><br> You can not do that, because $bizLoc would be tied to the Pattern type. Since you have different Pattern types, you will get the class cast exception. <br><br> Not sure if it is possible to improve variable declarations so that they can act on different patterns, but you may open a JIRA for us to investigate. <br>
<br> A workaround is if all your event classes implement an interface/super class that contains that attribute, you may bind the variable to the supertype attribute.<br><br> []s<br> Edson<br><br><div class="gmail_quote">
2009/5/14 Christoph Kramer <span dir="ltr"><<a href="mailto:amrod@gmx.de">amrod@gmx.de</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br>
i've some problems with a ClassCastException when using the "or"-conditional element.<br>
I have different Java-Beans which all have some string-values. Now I want to create one rule which is able to handle every type of my classes because it would be a lot of work to create one rule for every class.<br>
Depending on the type of beans in the working memory the programm is crashing with an ClassCastException.<br>
<br>
Here is a snippet of my drl-file with the "crashing-rule":<br>
<br>
rule "BizLocation"<br>
when<br>
$epc : EPC()<br>
QuantityEventType(epcClass == $epc.value ,$bizLoc: bizLocation !=null ) or AggregationEventType(childEPCs.epc contains $epc, $bizLoc : bizLocation != null) or ObjectEventType(epcList.epc contains $epc, $bizLoc : bizLocation != null)<br>
then<br>
System.out.println("BizLocation: " +$bizLoc.getId());<br>
end<br>
<br>
<br>
There are some EPC's in the working memory and some Events (which might be of type QuantityEventType, AggregationEventType or ObjectEventType). When there are only ObjectEventType in the working memory, everything works fine, but wenn there is an QuantityEventType this rule crashes with "org.fosstrak.epcis.model.QuantityEventType cannot be cast to org.fosstrak.epcis.model.ObjectEventType".<br>
I've lot of other, similar rules some of them crashing, others don't.<br>
<br>
<br>
Can anyone give me a hint where is the error?<br>
<br>
Thanks,<br>
Christoph<br>
<br>
PS: Sorry for the bad english :(<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>