You are confusing several issues here. I take it that the ClassCastException is<br>an error that occurs while you insert facts. At that time, all rule compiling has<br>been done and the rulebase has been built. A ClassCastException is not a<br>
problem of some class or other "being loaded" (by Java's own class loader);<br>it happens when you assign an object reference to a variable, and at that time<br>all involved classes have been "loaded".<br>
<br>Most importantly, rules are never "called". When you insert a fact, all<br>
Left Hand Side patterns where the fact's type (or supertype) is referenced<br>are evaluated against this fact. It's possible that this error occurs then,<br>for instance, if you use the Conditional Element "or". Or it could happen<br>
in a function called from there. We'd have to see the rules for a better guess.<br><br>-W<br><br><br><div class="gmail_quote">On Thu, May 21, 2009 at 10:29 AM, seemamani <span dir="ltr"><<a href="mailto:seemamani@gmail.com" target="_blank">seemamani@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
I have a rule in which I use objects of a class X. I compiled and packaged<br>
this rule using BRMS for which I uploaded a jar containing class X as the<br>
model. I use a rule agent to build a rulebase from this package. Now, when I<br>
pass the facts of type X to the rule engine, I get a ClassCastException<br>
saying that "X is incompatible with Y". Y is a subclass of X, but the<br>
problem is that a subclass object cannot be assigned to a superclass type.<br>
That means at some point, Y is getting loaded instead of X.<br>
<br>
I'm trying to identify at which point this is happening. In the above case,<br>
when does the class loading happen for the types used in a rule? Is it at<br>
step 1, 2 or 3 ?<br>
1. When the rule is compiled using MVEL?<br>
2. When the rule is called the first time?<br>
3. When the rulebase is built from the package?<br>
<br>
Thanks,<br>
Seema<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Class-loading-for-facts-used-in-rules-tp23649584p23649584.html" target="_blank">http://www.nabble.com/Class-loading-for-facts-used-in-rules-tp23649584p23649584.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<br>
<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>
</font></blockquote></div><br>