Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1166

ClassNotFoundException for the drools function when large number of valuations

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 7.0.0.Beta1
    • 6.4.0.Final
    • core engine
    • None
    • Workaround Exists
    • Hide

      When referencing static methods of a Java class, this error does not occur.

      With reference to attached reproducer, substituting all drools functions with static class reference F demonstrates the workaround solves the issue.
      i.e.: from

      mapOfList( $myC.stream().collect( groupingBy(entryKey())) ).entrySet().stream().filter( valueSizeGEof(2) ).count() >= 1)
      

      to

      mapOfList( $myC.stream().collect( groupingBy(F.entryKey())) ).entrySet().stream().filter( F.valueSizeGEof(2) ).count() >= 1)
      

      will avoid this error.

      Show
      When referencing static methods of a Java class, this error does not occur. With reference to attached reproducer, substituting all drools functions with static class reference F demonstrates the workaround solves the issue. i.e.: from mapOfList( $myC.stream().collect( groupingBy(entryKey())) ).entrySet().stream().filter( valueSizeGEof(2) ).count() >= 1) to mapOfList( $myC.stream().collect( groupingBy(F.entryKey())) ).entrySet().stream().filter( F.valueSizeGEof(2) ).count() >= 1) will avoid this error.
    • NEW
    • NEW

    Description

      Hello, for a large number of evaluations a ClassNotFoundException is thrown missing to find appropriate class for the drools function defined.

      In the attached reproducer, a for loop inserts a given number of facts into the session; for a small number of facts, no error is thrown.
      For example given

      for (int i=0; i<20; i++) {
      	session.insert("Ciao "+i);
      	session.fireAllRules();
      }
      

      all is fine.

      When running with say:

      for (int i=0; i<150; i++) {
      	session.insert("Ciao "+i);
      	session.fireAllRules();
      }
      

      then throws, snippet:

      java.lang.NoClassDefFoundError: com/acme/testjitfunction/EntryKey$1
      	at com.acme.testjitfunction.EntryKey.entryKey(EntryKey.java:51)
      	at ConditionEvaluator1fae754676b54e869aa5b558ba2d7991.evaluate(Unknown Source)
      	at org.drools.core.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:258)
      	at org.drools.core.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:214)
      	at org.drools.core.phreak.PhreakAccumulateNode.evaluateResultConstraints(PhreakAccumulateNode.java:696)
      	at org.drools.core.phreak.PhreakAccumulateNode.doNode(PhreakAccumulateNode.java:114)
      	at org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:534)
      [...]
      Caused by: java.lang.ClassNotFoundException: com.acme.testjitfunction.EntryKey$1
      	at java.lang.ClassLoader.findClass(ClassLoader.java:530)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      	at org.drools.core.common.ProjectClassLoader$DefaultInternalTypesClassLoader.loadType(ProjectClassLoader.java:393)
      	at org.drools.core.common.ProjectClassLoader$DefaultInternalTypesClassLoader.loadClass(ProjectClassLoader.java:380)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      	... 44 more
      

      I'm also wondering if maybe this is not the best possible way to "backport" lambdas as a drool function; in case a more proper way to implement them as a drool function is possible, kindly let me know.

      Can you kindly advise, please?

      Thank you very much
      Ciao
      MM

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            mmortari@redhat.com Matteo Mortari
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: