[rules-users] ClassCastException

Wolfgang Laun wolfgang.laun at gmail.com
Fri May 15 01:57:53 EDT 2009


I can't say for sure whether it would help since I don't know how all the
rules for the different *EventType classes are related, but you might have a
look at the "template" feature. Version 5.0 has an additional feature which
will let you create bunches of similar rules from a template, inserting
parameters from a collection of objects. Using this, the BizLocation rule
could be easily produced in triplicate, once for each EventType.

-W


On Thu, May 14, 2009 at 12:35 PM, Christoph Kramer <amrod at gmx.de> wrote:

> Hi all,
> i've some problems with a ClassCastException when using the
> "or"-conditional element.
> 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.
> Depending on the type of beans in the working memory the programm is
> crashing with an ClassCastException.
>
> Here is a snippet of my drl-file with the "crashing-rule":
>
> rule "BizLocation"
>   when
>       $epc : EPC()
>       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)
>   then
>       System.out.println("BizLocation: " +$bizLoc.getId());
> end
>
>
> 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".
> I've lot of other, similar rules some of them crashing, others don't.
>
>
> Can anyone give me a hint where is the error?
>
> Thanks,
> Christoph
>
> PS: Sorry for the bad english :(
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090515/97d4284a/attachment.html 


More information about the rules-users mailing list