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

Wolfgang Laun wolfgang.laun at gmail.com
Wed Sep 19 12:38:52 EDT 2012


The stack trace is suggestive of more complexity than you describe
with this simple rule and class.

mergePackage, removeRule: these methods aren't called due to a
simple fireAllRules() after inserting a few facts.

What's really going on here - some dynamic reconfiguration of the KB?

-W


On 19/09/2012, tosmun <taylor.osmun at ca.ibm.com> wrote:
> Hi All,
>
> I am having a very strange issue with my knowledge base... I have the
> following Rule:
>
> ...
> rule "root_host"
> no-loop true
> ruleflow-group 'initialize-appliance-definitions'
> when
> 	$app:ApplianceType
> 	(
> 		type == ApplianceTypeIdentifier.APPLIANCE_ROOT
> 	);
> 	not( ApplianceTypeObject() from $app.getObjectTypes());
> then
> 	//Do something
> end;
> ...
>
> And the ApplianceType class is defined as:
>
> ...
> public class ApplianceType
> {
> 	private ApplianceTypeIdentifier type;
> 	private List<ApplianceTypeObject> objectTypes;
> 	
> 	public ApplianceType(ApplianceTypeIdentifier type,
> List<ApplianceTypeObject> initialObjectTypes)
> 	{
> 		this.type = type;
> 		if(initialObjectTypes == null)
> 			this.objectTypes = new ArrayList<ApplianceTypeObject>();
> 		else
> 			this.objectTypes = initialObjectTypes;
> 	}
> 	
> 	public ApplianceType(ApplianceTypeIdentifier type)
> 	{
> 		this(type, null);
> 	}
> 	
> 	public ApplianceTypeIdentifier getType()
> 	{
> 		return type;
> 	}
>
> 	public List<ApplianceTypeObject> getObjectTypes() {
> 		return objectTypes;
> 	}
> }
>
> When attempting to fireAllRules() I receive the following error:
>
> ...
> Caused by: java.lang.ClassCastException: org.drools.reteoo.FromNode
> incompatible with org.drools.reteoo.BetaNode
> 	at org.drools.reteoo.ReteooBuilder.resetMasks(ReteooBuilder.java:303)
> 	at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:267)
> 	at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:459)
> 	at
> org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:1107)
> 	at
> org.drools.common.AbstractRuleBase.mergePackage(AbstractRuleBase.java:851)
> 	at
> org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:610)
> 	at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:472)
> 	at
> org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)
> 	at
> com.q1labs.frameworks.drools.DroolsEngine.getKnowledgeBase(DroolsEngine.java:139)
> 	at com.q1labs.frameworks.drools.DroolsEngine.onInit(DroolsEngine.java:50)
> 	at
> com.q1labs.frameworks.naming.FrameworksNaming.initializeNewComponent(FrameworksNaming.java:951)
> 	... 3 more
>
>
> Any thoughts? I have been using from clauses just like this throughout my
> project, and have had no issues with it to this point (even those which did
> not use generics).
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Issue-with-From-Clause-Class-Cast-Error-tp4019846.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list