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

tosmun taylor.osmun at ca.ibm.com
Wed Sep 19 12:06:30 EDT 2012


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.


More information about the rules-users mailing list