It would certainly make sense for this class to be Serializable, as most other classes in Jess are. The current implementation in practice contains an instance of java.util.ArrayList.Itr, which is not Seriaizable, so a certain amount of coding would be involved in making this change. Worth doing, though, so I'll see if we can work it in.
-----Original Message----- From: owner-jess-us...@sandia.gov [mailto:owner-jess-us...@sandia.gov] On Behalf Of Jonathan Sewall Sent: Monday, September 30, 2013 9:49 AM To: jess-users Subject: JESS: [EXTERNAL] bsave fails after defquery execution [was: Dynamic rule-base analysis] [Apologies for the incorrect Subject: on this report yesterday, 9/29.] The trouble with bsave after executing a defquery appears to happen when serializing the Map Context.m_variables in Rete.m_globalContext: at this point in the script, the map holds the QueryResult variable ?qr: (bind ?qr (run-query* all-cars)) Hence, if I execute (bind ?qr "not a QueryResult") before the 2nd bsave, then the script runs without error. Could QueryResult be made Serializable? Revised script and results below. Thanks again, Jonathan Sewall ------- Original Message -------- Subject: Re: JESS: [EXTERNAL] Dynamic rule-base analysis Date: Sun, 29 Sep 2013 18:04:11 -0400 From: Jonathan Sewall <sew...@cs.cmu.edu> Reply-To: jsew...@cmu.edu, jess-users@sandia.gov To: jess-users@sandia.gov ... Contents of script.clp: (deftemplate car (slot make) (slot model)) (defquery all-cars "Get all cars." ?car <- (car)) (defquery cars-of-make "Get cars of the given make." (declare (variables ?want-make)) ?car <- (car (make ?m&:(= ?m ?want-make)))) (reset) (bind ?pickup (assert (car (make "Ford") (model "F100")))) (bind ?sedan (assert (car (make "Honda") (model "Civic")))) (bind ?suv (assert (car (make "Ford") (model "Explorer")))) (printout t "*** Before 1st bsave ***" crlf) (printout t "globalContext " (((engine) getGlobalContext) toString) crlf) (bsave "s1.bsave") (bind ?qr (run-query* all-cars)) (while (?qr next) (bind ?car (?qr getObject "car")) (printout t (?car toString) crlf)) (?qr close) (printout t "*** Before 2nd bsave ***" crlf) (printout t "globalContext " (((engine) getGlobalContext) toString) crlf) ;; (bind ?qr "not a QueryResult") ;; uncomment to make script run ok (bsave "s2.bsave") Results: $ java -cp lib/jess.jar jess.Main Jess, the Rule Engine for the Java Platform Copyright (C) 2008 Sandia Corporation Jess Version 7.1p2 11/5/2008 Jess> (batch "script.clp") *** Before 1st bsave *** globalContext [Context, 3 variables: pickup=<Fact-1>;sedan=<Fact-2>;suv=<Fact-3>;] (MAIN::car (make "Ford") (model "F100")) (MAIN::car (make "Honda") (model "Civic")) (MAIN::car (make "Ford") (model "Explorer")) *** Before 2nd bsave *** globalContext [Context, 5 variables: car=<Java-Object:jess.Fact>;pickup=<Fact-1>;sedan=<Fact-2>;suv=<Fact-3>;qr=<Java-Object:jess.QueryResult>;] Jess reported an error in routine bsave while executing (bsave "s2.bsave") while executing (batch "script.clp"). Message: IO Exception. Program text: ( bsave "s2.bsave" ) at line 17 in file script.clp. Nested exception is: jess.QueryResult Jess> -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov. -------------------------------------------------------------------- -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov. --------------------------------------------------------------------