Printing out the ReteException object itself (i.e.,
toClient.println(re.toString())) would give you a helpful error
message; anytime you catch an exception, you should read the detail
message (with Jess or any other Java programming.) In this case, the
detail message will be: ReteException in routine
Jesp::parseFact. Message: Expected '( <atom>' at line 3: (assert ((.
Jess, like CLIPS, doesn't let the 'head' of a fact be the result of a
function call; the first assert in rule startup is illegal. Use
something like (assert (data (fetch A) (fetch B))) instead.
I find that when I'm embedding Jess into some other program, it's a
tremendous help to debug the rulebase first at the command line; only
when the rulebase is known to execute as expected would I proceed.
I think Beth Zhang wrote:
>
> Hi:
> I am developing a web-based application, which user can interactive with the
> Expert via the browser. So I was trying to use servlet which will pass the input
> data (from HTML form) to Jess and excute the .clp file. the output will pass to
> the servlet and be sent back to browser.
>
> I am using "fetch" and "store" for communicating between jess and java.
>
> The code in servlet is as follows:
>
> //get data from HTML form
> String namep="" ;
> String valuep="";
> Enumeration nameS = req.getParameterNames();
> while(nameS.hasMoreElements()) {
> namep = (String)nameS.nextElement();
> valuep = req.getParameterValues(namep)[0];
> }
>
> //excute .clp file,
> NullDisplay nd = new NullDisplay();
> Rete rete = new Rete(nd);
> rete.addUserpackage(new PredFunctions());
> try
> { rete.store("A", new Value(namep, RU.STRING));
> rete.store("B", new Value(valuep, RU.STRING));
>
> FileInputStream fis = new FileInputStream("test.clp");
> Jesp j = new Jesp(fis, rete);
> j.parse(false);
>
> //send the Jess PrintStream to browser
> toClient.println(nd.stdout());
> }
>
> // send error message to browser
> catch (ReteException re) {
> re.printStackTrace(nd.stderr());
> toClient.println("Rete Exception!");
> toClient.println(nd.stderr());
> }
> catch (FileNotFoundException e) {
> toClient.println("File not found!");
> }
>
> The code of test.clp is:
>
> (defrule startup
> =>
> (assert ((fetch A) (fetch B)))
> (assert (stage yn)))
>
> (defrule 1
> ?stage <- (stage yn)
> ?phase <- (phase yes)
> =>
> (printout t "YES" crlf))
>
> (defrule 2
> ?stage <- (stage yn)
> ?phase <- (phase no)
> =>
> (printout t "NO" crlf))
>
> (reset)
> (run)
>
> The running result is that rete exception is send to the browser. It seems that
> the test.clp file was not excuted.
>
> Can anybody help!
>
> Thanks!
>
>
> Beth Zhang
>
> Dept. of Civil Engineering
> National University of Singapore
> Tel: 65-8746498(o)
> Email: [EMAIL PROTECTED]
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
>
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (510) 294-2154
Sandia National Labs FAX: (510) 294-2234
Org. 8920, MS 9214 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------