Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: What is the Problem With This Code?

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default What is the Problem With This Code?

    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


  2. #2
    Junior Member
    Join Date
    Mar 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: What is the Problem With This Code?

    Please, can somebody help me out?

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: What is the Problem With This Code?

    Please, can somebody help me out?
    Probably not with the information you provided...the exception points you to the exact line of code where the error is occurring (returning the diagnosed disease) as well as what is happening (trying to get something from a Map that isn't there). Beyond that, since we don't what Rete is, we can't barely even guess

Similar Threads

  1. problem with code
    By Imeri0n in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 25th, 2011, 08:06 AM
  2. Problem with code
    By lichad3 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 22nd, 2011, 06:40 PM
  3. Problem with the code
    By noFear in forum What's Wrong With My Code?
    Replies: 10
    Last Post: August 9th, 2010, 10:28 AM
  4. problem in my code
    By wannabe in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 24th, 2010, 07:53 AM
  5. code needed for the following problem
    By romilc in forum Java Theory & Questions
    Replies: 1
    Last Post: October 11th, 2009, 10:05 AM