0 Replies Latest reply on Mar 19, 2013 6:00 AM by ankitd

    Not able to run the "Scorecard" rules from Java


      i belong to a development team, and in our product,  we are trying to bring in Drools inplace of Jrules.


      We are using Guvnor for creating rules and then trying to run the rules from our application(JAVA).We are able to run and execute the "Simple rules" as well as "Decision tables" from our application.


      Now we have requirement of "Scorecard" in our application, which is one the module in the latest release of Drools(5.5.0).


      Here is the approach we have taken:


      Inside the Guvnor UI

      1) Created the Package called org.scorecard.

      2) Uploaded the Pojo model jar containg class Person(int:age,String:residence,double:personScore). Validated and saved it.

      3) Created the Category "personCategory".

      4) Then added the Scorecard rule using as Scorcard(Web Guided Editor) type. Validated and saved it

      5)  Created the Package snapshot and copied the Url for using it inside the person-changeset.xml file.Here is how it looks:



      <?xml version="1.0" encoding="UTF-8"?>

      <change-set xmlns="http://drools.org/drools-5.0/change-set"


        xs:schemaLocation="http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd">


          <!-- Note: the host (localhost), port (8080) and context root (guvnor) might be different

               depending on your app server configuration and war filename. -->

          <resource source="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/org.person/personSnapshot"

              type="PKG" basicAuthentication="enabled" username="admin" password="admin" />




      Here is the Java client code that i am using to run the rules.

      StatefulKnowledgeSession ksession = null;

      KnowledgeBase kbase = readKnowledgeBase();

      Person person =new Person();





      ksession = kbase.newStatefulKnowledgeSession();



      String message = "Message is:\n" + person.getPersonScore();


      JOptionPane.showMessageDialog(null, message, "Result", JOptionPane.INFORMATION_MESSAGE);

      if (ksession != null) {





          private static KnowledgeBase readKnowledgeBase() {

              KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("MortgageAgent");

              Resource changeset = ResourceFactory.newClassPathResource(



              KnowledgeBase kbase = kagent.getKnowledgeBase();


              return kbase;




      At the end of the execuiton, its expected that the personScore attribute of the person object created stroes the final score based on the rules excuted.

      Everytime i am getting same value ie. 0.0


      we are using tomcat for running the Guvnor.I have deployed the drools_guvnor.war(5.5.0 version) inside the webapps folder.

      In the tomacat/lib folder have added the following jars:






      Also my Java class path looks like this.








      When running the simple rules and decision tables the application is running smooth and giving the expected o/p.In both the cases we are taking Decalrative model approach and we are creating Facts inside Guvnor itself.


      For Scorecard we have to take the "Upload Pojo Model Jar" approach as "Resultant score" field expects a attribute of "double" type and inside the Fact its not possible to create the double type attribute.Even if you try to create a fact attribute

      with decimal Number type it does considers it as "Resultant score " field. So the only option left was to upload Pojo model jar.


      i want to know where we are goin wron incase of scorecard.

      Any help would be appreciated.