[rules-users] Issue with From Clause - Class Cast Error

Mario Fusco mario.fusco at gmail.com
Thu Sep 20 06:02:10 EDT 2012


Hi Taylor,

I must say I took a while to reproduce this problem. I knew there could be
something wrong because I couldn't reproduce it neither on the 5.5.x
(master) branch nor on the 5.4.x one and that was weird because I pushed the
fix linked by Davide on the master branch but I didn't backport it on the
5.4.x.

Moreover, after a deeper look, I realized that the fix was strictly related
with a brand new feature I added during the development of the 5.5.0 release
(the indexing for comparison constraints) and that's why I didn't backport
it to the 5.4.x branch. Nevertheless I also couldn't find any other commit
subsequent the deploy of the release 5.4.0.Final that could have been
possibly related with your issue. 

In a word I was pretty sure that the problem you found was still there, so I
continued investigating to try to reproduce it. At this point something
wrote by Wolfgang in his first reply made me ring a bell: why was removeRule
invoked in the stack of your ClassCastException?

Actually there are only 2 reasons why a rule should be removed from the
KnowledgeBase: either you were explicitly invoking the removeRule() method
(and apparently you weren't doing that) or you were adding a rule with the
same name (and in the same package) twice and in this case the old rule is
automatically removed to be replaced with the new one.

In the end I've been able to reproduce the same exception you reported just
repeating TWICE the statement:

kb.addKnowledgePackages(kbBuilder.getKnowledgePackages()); 

Indeed the second invocation of addKnowledgePackages() causes the 2 rules to
be readded to the KnowledgeBase and to do so the old ones having the same
name have to be removed. I then suspect you're involuntarily doing the same
in your code and that could also explain why you wrote that removing (I'd
say one of the two) addKnowledgePackages() fixes your problem.

The bottom line is that the ClassCastException is still there (both on the
master and the 5.4.x branches) and I am working just now to fix it. Thanks
for having reported it.

Cheers,
Mario



--
View this message in context: http://drools.46999.n3.nabble.com/Issue-with-From-Clause-Class-Cast-Error-tp4019846p4019868.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list