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

Calling static Java method from DMN model (Drools Business Central)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Critical Critical
    • None
    • 7.40.0.Final
    • DMN Editor
    • Hide

      1) In Eclipse (I'm using version 2020-02(4.15.0)), create new Maven project (archetype: groupid: org.apache.maven.archetype, artifactId: maven-archetype-quickstart)

      2) Add new StandardDeviationA class (update package name as required):

       

      package com.samplea.drools.DroolsNewTypes5;
      import java.math.BigDecimal;
      public class StandardDeviationA {
           public static BigDecimal stdev_a(java.lang.Number val) { 
              return new BigDecimal(val.doubleValue() * 2); 
          }
      }
      

       

      3) Right-click on new project, choose Run As -> Maven Install 

      4) Copy location of generated .jar file

      5) In Business Central, go to Artifacts (click cog in the top right hand corner, choose Artifacts icon)

      6) Add new artifact by clicking upload and choosing location of .jar from step 4)

      7) Go to the project in Business Central Space (or create new project).

      8) In the project, click on Settings tab (top). Go to Dependencies tab (left). 

      9) Click "Add from repository" link.

      Add jar as:

              group id: com.samplea.drools 

              artifact ID: DroolsNewTypes5 

              version 0.0.1-SNAPSHOT   

              package whitelist: All   

      Click Save

      10) Go to Assets tab (top). Add new Asset.

      In new asset, add BKM (business knowledge model) element

      11) Double click BKM element to go to details. Configure it as follows:

      function kind: Java (J)

      class: "com.samplea.drools.DroolsNewTypes5.StandardDeviationA"

      method signature: "stdev_a(java.lang.Number)"

       

      Click Save button (top)

      Alerts pane shows the error

       

       

      Show
      1) In Eclipse (I'm using version 2020-02(4.15.0)), create new Maven project (archetype: groupid: org.apache.maven.archetype, artifactId: maven-archetype-quickstart) 2) Add new StandardDeviationA class (update package name as required):   package com.samplea.drools.DroolsNewTypes5; import java.math.BigDecimal; public class StandardDeviationA { public static BigDecimal stdev_a(java.lang. Number val) { return new BigDecimal(val.doubleValue() * 2); } }   3) Right-click on new project, choose Run As -> Maven Install  4) Copy location of generated .jar file 5) In Business Central, go to Artifacts (click cog in the top right hand corner, choose Artifacts icon) 6) Add new artifact by clicking upload and choosing location of .jar from step 4) 7) Go to the project in Business Central Space (or create new project). 8) In the project, click on Settings tab (top). Go to Dependencies tab (left).  9) Click "Add from repository" link. Add jar as:         group id: com.samplea.drools          artifact ID: DroolsNewTypes5          version 0.0.1-SNAPSHOT            package whitelist: All    Click Save 10) Go to Assets tab (top). Add new Asset. In new asset, add BKM (business knowledge model) element 11) Double click BKM element to go to details. Configure it as follows: function kind: Java (J) class: "com.samplea.drools.DroolsNewTypes5.StandardDeviationA" method signature: "stdev_a(java.lang.Number)"   Click Save button (top) Alerts pane shows the error    
    • NEW
    • NEW

      When calling static Java method stdev_a (which I created in a new Java Maven project) from Drools Business Central DMN project/model, I'm getting following error:

       

      DMN: Error compiling Java function 'stdev' on node 'stdev': Error resolving external function as defined by: function(val) external { java: { class: ""com.samplea.drools.DroolsNewTypes5.StandardDeviationA"", method signature: ""stdev_a(java.lang.Number)"" }} (DMN id: _3B4B6CBE-847B-4488-8754-214F506BBB48, Error compiling the referenced FEEL expression)

       

      Also, how to view logs of DMN model when it has build errors? 

        1. Artifacts.PNG
          11 kB
          K M
        2. Artifacts0.PNG
          12 kB
          K M
        3. dependencies.PNG
          17 kB
          K M
        4. stdev 0.PNG
          19 kB
          K M
        5. stdev 1.PNG
          30 kB
          K M

              karreiro_ Guilherme Gomes (Inactive)
              tmandekic K M (Inactive)
              Barbora Kapustova Barbora Kapustova
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: