[rules-users] traits - don more than 3 pojos, got IllegalArgumentException

bdolbeare bdolbeare at yahoo.com
Tue May 15 14:33:59 EDT 2012


After upgrading to 5.4.0 Final, I can get traits to work with
StatefulKnowledgeSessions but, using a StatelessKnowledgeSession, the same
DRL fails with a java.lang.IllegalArgumentException:


When run with StatefulKnowledgeSessions, I get this output:

(@traits.MyTraittraitsMyFactProxy) : [<<id=0>>]
MyFact( id=0 )


When run with StatelessKnowledgeSession, I get this output:
null
Exception executing consequence for rule "Add trait" in traits:
java.lang.IllegalArgumentException: argument type mismatch
	at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
	at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1283)
	at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1209)
	at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1442)
	at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
	at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
	at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
	at
org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:278)
	at test.traits.SimpleTest.runTest_Stateless(SimpleTest.java:61)
	at test.traits.SimpleTest.runTest(SimpleTest.java:51)
	at test.traits.SimpleTest.main(SimpleTest.java:39)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.drools.factmodel.traits.TraitFactory.getProxy(TraitFactory.java:114)
	at
org.drools.base.DefaultKnowledgeHelper.don(DefaultKnowledgeHelper.java:522)
	at
traits.Rule_Add_trait_206a55ec742b4133b1adcca26f22e8ef.defaultConsequence(Rule_Add_trait_206a55ec742b4133b1adcca26f22e8ef.java:14)
	at
traits.Rule_Add_trait_206a55ec742b4133b1adcca26f22e8efDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
	at
traits.Rule_Add_trait_206a55ec742b4133b1adcca26f22e8efDefaultConsequenceInvoker.evaluate(Unknown
Source)
	at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1273)
	... 9 more


Here is the DRL I am using:


package traits

declare trait MyTrait end

declare MyFact
	@Traitable
	id : int 
end

rule "create fact"
	when
		eval(true)
	then
		MyFact d = new MyFact(0);
		insertLogical(d);
end	

rule "dump facts"
	when
		d : MyFact()
	then
		System.out.println(d);
end	

rule "dump traits"
	when
		d : MyTrait()
	then
		System.out.println(d);
end	

rule "Add trait"
	when 
		d : MyFact ( eval (id % 2 == 0) )
	then				
		don( d, MyTrait.class, true );
end

--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-traits-don-more-than-3-pojos-got-IllegalArgumentException-tp3788670p3988622.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list