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