I wrote a JavaBean to interface with another third party application but I am having the error below:
Caused by: java.util.NoSuchElementException
at java.util.HashMap$HashIterator.nextEntry(HashMap.j ava:796)
at java.util.HashMap$KeyIterator.next(HashMap.java:82 8)
at voiceexpert.DiagnosingEngine.execute(DiagnosingEng ine.java:33)
at voiceexpert.Symptoms.process(Symptoms.java:57)
... 21 more
I think the problem is in the "DiagnosingEngine" class, especially tne portion below:
// Return the Disease diagnosed
return (Disease) engine.getObjects(new Filter.ByClass(Disease.class)).next();
I need your assistance please!
The whole code is as below:
package voiceexpert; import java.io.Serializable; /** * * @author Oyelami */ public class Symptoms implements Serializable{ private String s1, s2, s3, result; private Disease diseaseobject; public void setS1(String symptom1) { this.s1=symptom1; } public void setS2(String symptom2) { this.s2=symptom2; } public void setS3(String symptom3) { this.s3=symptom3; } public Symptoms() { } public Symptoms(String symptom1, String symptom2,String symptom3) { s1=symptom1; s2=symptom2; s3=symptom3; } public String getS1() { return s1; } public String getS2() { return s2; } public String getS3() { return s3; } public String process() { DiagnosingEngine engine = new DiagnosingEngine(s1,s2,s3); diseaseobject=engine.execute(); result = diseaseobject.diagnosis; return result; } public String getResult() { return result; } }// end of class Symptoms
package voiceexpert; public class Disease { public String diagnosis; public Disease(String thediagnosis) { diagnosis=thediagnosis; } } package voiceexpert; import jess.JessException; import jess.*; public class DiagnosingEngine { private Rete engine; private WorkingMemoryMarker marker; public DiagnosingEngine(String symptom1, String symptom2, String symptom3) { try{ // create a Jess rule engine engine = new Rete(); engine.reset(); //Load the rules engine.batch("diagnosingvoice.clp"); // Create a new Symptom object and initialize with the syptoms supplied by the caller Symptoms s =new Symptoms(symptom1, symptom2, symptom3); // Load the symptoms into the working memory engine.add(s); // mArk the end of symptoms for later marker = engine.mark(); } catch(JessException e){} } public Disease execute() { try{ // Fire the rules that apply to those symptoms engine.run(); } catch (JessException e){} // Return the Disease diagnosed return (Disease) engine.getObjects(new Filter.ByClass(Disease.class)).next(); } }// end of class DiagnosingEngine