RE: JESS: Fact object not in working memory error
My guess would be that the Focus is in MAIN (or some other module that you might have defined) and not in STATE-CLEANUP where the fact resides (I am assuming that the fact resides in STATE_CLEANUP since that is where the rule that caused the error resides). Do a (watch focus) to see where the focus is at the time of the error. Scott Scott L. Krasnigor Principal Engineer/Scientist Advanced Sciences Technologies, LLC. Lockheed Martin - MS2 ' 856-359-3094 * [EMAIL PROTECTED] * 780-3 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hasan Khan Sent: Thursday, August 31, 2006 12:07 PM To: jess-users@sandia.gov Subject: JESS: Fact object not in working memory error Hello, I get the following error when trying to execute the code: (defrule STATE-CLEANUP::Clean2 remove all facts generated for a pid (declare (salience -508)) ?f1 - (MAIN::domain-state-req-cleanup(pid ?pid)) ?f2 - (STATE-PROCESSING::valid-action(pid ?pid)) = (modify ?f2 (object nil)) (retract ?f2) ) The stack trace of the error is: Caused by: Jess reported an error in routine modify while executing (modify ?f2 (object nil)) while executing defrule STATE-CLEANUP::Clean2. Message: Fact object not in working memory (STATE-PROCESSING::valid-action (oid 17449694) (pid gen113) (object Java-Object:fleetcycle.domain.es.taskCardAssignment.TaskCardGroupAssignment) (action taskCardAssignment.removeTaskCardGroupAssignment) (name removeTaskCardGroupAssignment) (allowed TRUE) (parentState nil) (validationErrors nil)). at jess.FactList.modifyRegularFact(FactList.java:306) at jess.FactList.modify(FactList.java:242) at jess.Rete.modify(Rete.java:492) at jess.Modify.call(Modify.java:31) at jess.FunctionHolder.call(FunctionHolder.java:31) at jess.Funcall.execute(Funcall.java:257) at jess.Defrule.fire(Defrule.java:252) at jess.Activation.fire(Activation.java:84) at jess.Agenda.run(Agenda.java:259) at jess.Agenda.run(Agenda.java:235) at jess.Rete.run(Rete.java:1360) at fleetcycle.model.framework.rules.RulesProcessCleanup.cleanUp(RulesProcessCleanup.java:42) Any help would be really appreciated. Thanks Hasan Confidentiality Notice: ** This E-mail and any attachments thereto, are intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this E-mail, you are hereby notified any dissemination, distribution or copying of this E-mail, and any attachments thereto, is strictly prohibited. If you receive this E-mail in error, please immediately notify me by reply E-mail or telephone at (218) 723-7887 and permanently delete the original and any copy of this E-mail, and any printout thereof.
Re: JESS: Fact object not in working memory error
Most likely the problem is that some of your classes (perhaps com.ngc.dts.domain.common.PerDiemEntitlement) have mutable hash codes, making them unsuitable for use as keys in a hash table (try using one of these objects as a key in a HashMap, change the values of some properties, then try to look up the same object; it will fail) and some properties of these objects are being modified outside of a (modify) call. This causes problems in Jess 6. Jess 7 works around this by providing a function that lets you warn Jess about this issue for a particular class. I think erich.oliphant wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] I am having a strange problem. I am getting the following error (debug included). The populate-last-travel-day rule fires based on the presence of facf-5 (among others). The error is thrown in the rule body where I try to modify f-5. I am not sure how the fact cannot be in working memory as the rule fired because of it's existence (and I'm not retracting it) The body of the rule only modifies this fact and asserts a new one. These rules are driven from Java code and verified that the supporting Java object still exists at the time the exception is thrown. rule -- (defrule populate-last-travel-day-entitlement first day at perdiem location entitlement ?arrlocation - (com.ngc.dts.domain.common.TripLocation (arrivalTripItem ?ati) (perDiemLocation ?x:(eq ?x nil))) (test (neq (?ati getTravelDate) nil)) ?perdiemLocation - (com.ngc.dts.domain.common.TripLocation (departureTripItem ?dti) (perDiemLocation ?pdLocation:(neq ?pdLocation nil))) ?entitlement - (com.ngc.dts.domain.common.PerDiemEntitlement (date ?pddate) ) ;;@todo investigate why same-day is not working as expected ;;(test (neq (same-day (?dti getTravelDate) ?date) FALSE) ) (test (call org.apache.commons.lang.time.DateUtils isSameDay (?ati getTravelDate) ?pddate)) (test (call org.apache.commons.lang.time.DateUtils isSameDay (?dti getTravelDate) (?ati getTravelDate))) (not (travel-day (date ?pddate))) = ;; get the per (bind ?mie (ognl-get ?pdLocation getEffectivePerDiemRate(#date).getMealsAndIncidentalsRate() date (fact-slot-value ?entitlement date))) (modify ?entitlement (perDiemLocation ?pdLocation) (mealsAndIncidentalsAllowed (?mie multiply .75))) (assert (travel-day (date ?pddate))) ) -- debug and error -- MAIN::populate-first-travel-day-entitlement: +1+1+1+2+1+2+1+2+1+2+2+2+t MAIN::populate-last-travel-day-entitlement: =1=1=1+2=1+2=1+2+2+2=1+2+t MAIN::populate-full-perdiem-day-entitlements: =1=1+1+2+2=1+2+2+2+1+2+t MAIN::assign-cmr: =1+1+1=1+2+2+2+2+a+2+t MAIN::assign-pmr: =1=1=1=1=2+2+t MAIN::assert-entitlements: +1+1+t MAIN::assign-gmr: =1=1=1=1=2+2+2+2+t MAIN::zero-allowed-duty-conditions: =1+1+1+1+2+t MAIN::actual-lodging: =1=1=1=1+2+t MAIN::assert-entitlements: +1+1+t == f-0 (MAIN::com.ngc.dts.domain.common.Trip (auth Java-Object:com.ngc.dts.domain.common.Authorization) (class Java-Object:java.lang.Class) (documentKey nil) (endDate nil) (endLocation nil) (id nil) (startDate nil) (startLocation nil) (taNumber nil) (travelOrderComments nil) (tripDescription nil) (tripDuration nil) (tripLocations Java-Object:java.util.ArrayList) (tripNumber 1) (tripProfile nil) (tripPurpose nil) (tripType nil) (OBJECT Java-Object:com.ngc.dts.domain.common.Trip)) == Activation: MAIN::assert-entitlements : f-0 FIRE 1 MAIN::assert-entitlements f-0 == f-1 (MAIN::com.ngc.dts.domain.common.PerDiemEntitlement (acutalLodgingCostLimit nil) (class Java-Object:java.lang.Class) (date Java-Object:java.util.GregorianCalendar) (dutyConditions Java-Object:java.util.HashSet) (leave nil) (lodgingAllowed nil) (lodgingExpense Java-Object:com.ngc.dts.domain.common.Expense) (mealsAndIncidentalsAllowed nil) (mealsAndIncidentalsExpense Java-Object:com.ngc.dts.domain.common.Expense) (otherEntitlementType nil) (perDiemLocation nil) (OBJECT Java-Object:com.ngc.dts.domain.common.PerDiemEntitlement)) ent date from code: 01/01/2006 12:00 PM == f-2 (MAIN::com.ngc.dts.domain.common.PerDiemEntitlement (acutalLodgingCostLimit nil) (class Java-Object:java.lang.Class) (date Java-Object:java.util.GregorianCalendar) (dutyConditions Java-Object:java.util.HashSet) (leave nil) (lodgingAllowed nil) (lodgingExpense Java-Object:com.ngc.dts.domain.common.Expense) (mealsAndIncidentalsAllowed nil) (mealsAndIncidentalsExpense Java-Object:com.ngc.dts.domain.common.Expense) (otherEntitlementType nil) (perDiemLocation nil) (OBJECT Java-Object:com.ngc.dts.domain.common.PerDiemEntitlement)) ent date from code: 01/02/2006 12:00 PM == f-3 (MAIN::com.ngc.dts.domain.common.PerDiemEntitlement (acutalLodgingCostLimit nil) (class Java-Object:java.lang.Class) (date