0

I am trying to implement drools decision table. When i implemented my own sample code i am getting below error : java.lang.RuntimeException: Error while creating KieBase.

The error visible in console of my Eclipse IDE is :

java.lang.RuntimeException: Error while creating KieBase[Message [id=1, kieBase=patient, level=ERROR, path=PatientDecisionTable.xls, line=10, column=0 text=[ERR 101] Line 10:21 no viable alternative at input ''], Message [id=2, kieBase=patient, level=ERROR, path=PatientDecisionTable.xls, line=10, column=0 text=[ERR 101] Line 10:81 no viable alternative at input ''], Message [id=3, kieBase=patient, level=ERROR, path=PatientDecisionTable.xls, line=0, column=0 text=Parser returned a null Package]] at org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:557) at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:682) at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:650) at com.Lab.Genomics.Run.PatientRun.main(PatientRun.java:15)

My Main method is contained in below class:

import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import com.Lab.Genomics.model.Patient;

    public class PatientRun {

        public static void main(String[] args) {
            // TODO Auto-generated method stub
            try{
                KieServices ks= KieServices.Factory.get();
                KieContainer kContainer=ks.getKieClasspathContainer();
                KieSession kSession= kContainer.newKieSession("ksession-patient");

                Patient patientObject= new Patient();
                patientObject.setBcConfirmed(1);
                patientObject.setBcEarlyStage(1);
                patientObject.setMetastatisSymptom(1);
                patientObject.setName("Sumit");
                patientObject.setPatientId(01);
                kSession.insert(patientObject);
                kSession.fireAllRules();



            }catch(Exception e){
                e.printStackTrace();
            }
        }

    }

Patient is my pojo. My decision table is as below: Decision Table for Project

My project directory is as below: Project directory

I am unable to find what error is present in the decision table . When i run the main method i get error as mentioned above.

I found a question for drools decision table here decision table error , but this not my case as i checked.

I have tried searching and still trying. Any reference or help is highly appreciated.

Vikram
  • 332
  • 3
  • 16

1 Answers1

2

Avoid the quotes Excel provides by default. You have them around the string in the println call: LEFT DOUBLE QUOTATION MARK, U+201C RIGHT DOUBLE QUOTATION MARK, U+201D

if I type these keystrokes into an Excel cell: 'A' ' ' 's' ... ':' ' ' '"' 'o' ... 'e' 'e' '"' I'll see this:

A string: “one two three”

Now I copy-paste it into a text file and run a dump program on it:

0000000 41 20 73 74 72 69 6e 67 3a 20 e2 80 9c 6f 6e 65
0000020 20 74 77 6f 20 74 68 72 65 65 e2 80 9d 0a

See the UTF-8 encodings: 0xE2 0x80 0x9C and 0xE2 0x80 0x9D for the quotes, which aren't the ones permitted in DRL code. Make sure to use the quotation mark, code point U+0022. This is it: ->"<-

laune
  • 31,114
  • 3
  • 29
  • 42
  • cannot understand what do you mean by "Avoid the quotes Excel provides by default. (You have them around the string in the println call.)Make sure to use the quotation mark, code point U+0022" . I have used the quotation marks in the println and those are not default as i checked. Can you plz elaborate a bit. – Vikram Oct 20 '17 at 11:05
  • I removed the quotation mark and the string altogether. Now just have a getter method inside sysout. Getting error: java.lang.RuntimeException: Error while creating KieBase[Message [id=1, kieBase=patient, level=ERROR, path=PatientDecisionTable.xls, line=5, column=0 text=Rule Compilation error Go cannot be resolved to a variable Syntax error on token "for", invalid AssignmentOperator test cannot be resolved to a variable]] – Vikram Oct 20 '17 at 11:28
  • You don't have any quotes around the string `Go for test`. – laune Oct 20 '17 at 11:34
  • Re quotes in Excel: You need to learn about character sets. Take care: these office programs may sneak up on you and change what you type. – laune Oct 20 '17 at 11:35
  • Ok . By default open office uses LEFT DOUBLE QUOTATION MARK, U+201C as left quotation mark which needs to be avoided. Now i removed the quotation altogether i am getting the error: – Vikram Oct 20 '17 at 12:20
  • java.lang.RuntimeException: Error while creating KieBase[Message [id=1, kieBase=patient, level=ERROR, path=PatientDecisionTable.xls, line=10, column=0 text=[ERR 101] Line 10:15 no viable alternative at input ''], Message [id=2, kieBase=patient, level=ERROR, path=PatientDecisionTable.xls, line=10, column=0 text=Parser returned a null Package]]. I checked and found that Line 10:15 represent line 10 and column 15. There isn't any character at the error location ' ' though. Any suggestions. – Vikram Oct 20 '17 at 12:22
  • Not sure how tolerant the parser is but you might need a semicolon after the update call. – laune Oct 20 '17 at 15:53
  • Updated the decision table. The exception points to line 9 instead of 10. java.lang.RuntimeException: Error while creating KieBase[Message [id=1, kieBase=patient, level=ERROR, path=PatientDecisionTable.xls, line=9, column=0 text=[ERR 101] Line 9:15 no viable alternative at input ''], Message [id=2, kieBase=patient, level=ERROR, path=PatientDecisionTable.xls, line=9, column=0 text=[ERR 101] Line 9:27 no viable alternative at input ''], Message [id=3, kieBase=patient, level=ERROR, path=PatientDecisionTable.xls, line=0, column=0 text=Parser returned a null Package]] – Vikram Oct 23 '17 at 05:23
  • Quotes, again the wrong ones in your spreadsheet. Dig into Excel, try to find something like "Deactivating automatic changes" and stop the automatic replacement, delete the old quotes and insert 0x0022. - How long do you use computers?? – laune Oct 23 '17 at 07:55
  • Changing the default quotes to 0x0022 worked. Accepted the answer with edit. – Vikram Oct 23 '17 at 10:32