[rules-users] traits - don more than 3 pojos, got IllegalArgumentException
Mauricio Salatino
salaboy at gmail.com
Wed Feb 29 16:15:56 EST 2012
Hi Michal,
You need to change this:
declare NiceMessage
@format(trait)
end
to this:
declare trait NiceMessage
..
end
Cheers
2012/2/29 Michal Bali <michalbali at gmail.com>
> Hi all,
>
> I came across this issue when trying out 'traits' with POJOs (not declared
> types). An IllegalArgumentException is being thrown when I apply the third
> 'don'. Here is how to reproduce:
> as the POJO I am using the Message class that comes with the project
> created by the Eclipse plugin.
> now the rule file:
>
> declare Message
> @Traitable
>
> end
>
> declare NiceMessage
> @format(trait)
>
> end
>
> rule load
> when
>
> then
> Message message = new Message();
> message.setMessage("Hello World");
> insert(message);
> don(message, NiceMessage.class);
>
> Message unreadMessage = new Message();
> unreadMessage.setMessage("unread");
> insert(unreadMessage);
> don(unreadMessage, NiceMessage.class);
>
> Message oldMessage = new Message();
> oldMessage.setMessage("old");
> insert(oldMessage);
> System.out.println("don " + oldMessage);
> don(oldMessage, NiceMessage.class); //*<--- exception happens here
> *
> System.out.println("wont reach this point");
> end
>
> When I run this and rule 'load' fires the third 'don' will throw the
> following exception:
>
> Exception executing consequence for rule "load" in com.mycompany.app:
> 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:1101)
> at
> org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
> at
> org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251)
> at
> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:709)
> at
> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:673)
> at
> org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:221)
> at com.mycompany.app.DroolsTest.main(DroolsTest.java:44)
> Caused by: java.lang.IllegalArgumentException: argument type mismatch
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
> at
> org.drools.factmodel.traits.TraitFactory.getProxy(TraitFactory.java:92)
> at
> org.drools.base.DefaultKnowledgeHelper.don(DefaultKnowledgeHelper.java:502)
> at
> org.drools.base.DefaultKnowledgeHelper.don(DefaultKnowledgeHelper.java:522)
> at
> com.mycompany.app.Rule_load_86ecf966a4c14d8486844cfae2e1e0d8.defaultConsequence(Rule_load_86ecf966a4c14d8486844cfae2e1e0d8.java:21)
> at
> com.mycompany.app.Rule_load_86ecf966a4c14d8486844cfae2e1e0d8DefaultConsequenceInvokerGenerated.evaluate(Unknown
> Source)
> at
> com.mycompany.app.Rule_load_86ecf966a4c14d8486844cfae2e1e0d8DefaultConsequenceInvoker.evaluate(Unknown
> Source)
> at
> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
> ... 6 more
>
> Am I doing something wrong or is this a bug. I am running with 5.4.0.Beta2.
>
> BTW traits are a great piece of functionality. Thank you!
>
> Best regards,
> Michal
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jugargentina.org
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120229/d877cffb/attachment.html
More information about the rules-users
mailing list