Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-3412

traits - don more than 3 pojos, got IllegalArgumentException

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 5.4.0.CR1
    • 5.4.0.Beta2
    • drools-compiler
    • None
    • Hide

      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

      Show
      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

    Description

      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'.

      Attachments

        Activity

          People

            dsotty Davide Sottara (Inactive)
            michalbali_jira Michal Bali (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

            Dates

              Created:
              Updated:
              Resolved:
              Archived:

              PagerDuty