I've done a little more checking into the ReteException
I was getting while running my modified pumps example.
It turns out that I can cause the exception to occur regardless
of my addition or removal of objects.
[Although in the process of working through this, I
have a number of potential mods to jess\relect\ReflectFunctions.java
that I'll append to the end of this note.]
One can start with Jess5.0a2 as delivered, and replace the line
rete.executeCommand("(run)");
in jess\examples\pumps\MainInJava.java with
while (true) rete.executeCommand("(run 1)");
After a while, you'll get:
Rete Exception in routine NodeNot2::RunTestsVaryLeft while executing rule
LHS: [NodeNot2 ntests=1 [Test2:
test=EQ;tokenIdx=0;leftIdx=7;leftSubIdx=-1;rightIdx=2;rightSubIdx=1]
;usecount = 1] while executing defrule raise-rate-if-low.
Message: Corrupted Negcnt (< 0) at line 0: ( run 1 ) .
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at jess.ReteException.<init>(Compiled Code)
at jess.NodeNot2.runTestsVaryLeft(Compiled Code)
at jess.NodeNot2.runTestsVaryLeft(Compiled Code)
at jess.Node2.callNode(Compiled Code)
at jess.Node.passAlong(Compiled Code)
at jess.Node1MTEQ.callNode(Node1.java:665)
at jess.Node.passAlong(Compiled Code)
at jess.Node1MTELN.callNode(Node1.java:705)
at jess.Node.passAlong(Compiled Code)
at jess.Node1TECT.callNode(Compiled Code)
at jess.Rete.processTokenOneNode(Compiled Code)
at jess.Rete.processToken(Compiled Code)
at jess.Rete._retract(Compiled Code)
at jess.Retract.call(Compiled Code)
at jess.Funcall.simpleExecute(Compiled Code)
at jess.Funcall.execute(Compiled Code)
at jess.Funcall.execute(Compiled Code)
at jess.Defrule.fire(Compiled Code)
at jess.Activation.fire(Compiled Code)
at jess.Rete.run(Compiled Code)
at jess.HaltEtc.call(Compiled Code)
at jess.Funcall.simpleExecute(Compiled Code)
at jess.Funcall.execute(Compiled Code)
at jess.Funcall.execute(Compiled Code)
at jess.Jesp.parseAndExecuteFuncall(Compiled Code)
at jess.Jesp.parseSexp(Compiled Code)
at jess.Jesp.parse(Compiled Code)
at jess.Rete.executeCommand(Compiled Code)
at jess.examples.pumps.MainInJava.main(Compiled Code)
>From a quick look at the implementation of Run, I wouldn't
expect this change to cause any exceptions to be thrown, but
low and behold, it does. Thinking this could be due to
using the brand new MS Java (build 3165), I rebuilt with Javasoft
Java 1.1.6 and get the same behavior.
Any thoughts?
===================================================================
Here are the potential changes to jess\relect\ReflectFunctions.java
that I mentioned. Note that I'm not suggesting people blindly apply
these - my knowledge of the JESS internals is insufficient to know
what the full effects of these changes might be.
Change
------
public Value call(ValueVector vv, Context context) throws ReteException
To
--
public synchronized Value call(ValueVector vv, Context context) throws
ReteException
Change the definition of undefine to
-------------------------------------
// make undefine synchronized so we don't undefine while in use via
propertyChange or ???
synchronized Value undefine(Object o) throws ReteException
{
boolean b_remove_result;
Fact f = (Fact) m_facts.get(o);
if (f != null)
m_engine.retract(f.factData());
m_facts.remove(o);
b_remove_result = m_jessClasses.remove(o) == null;
// Remove ourselves from the object as a PropertyChangeListener
try {
Class pcl = Class.forName("java.beans.PropertyChangeListener");
Method apcl =
o.getClass().getMethod("removePropertyChangeListener",
new Class[] { pcl });
apcl.invoke( o, new Object[] { this });
}
catch (InvocationTargetException ite)
{
throw new ReteException("undefinstance",
"Cannot remove PropertyChangeListener",
ite.getTargetException().toString());
}
catch (NoSuchMethodException nsm)
{
throw new ReteException("undefinstance",
"Obj doesn't accept PropertyChangeListeners",
"");
}
catch (ClassNotFoundException cnfe)
{
throw new ReteException("undefinstance", "Class not found", "");
}
catch (IllegalAccessException iae)
{
throw new ReteException("undefinstance",
"Class or method is not accessible",
"");
}
if (b_remove_result)
return Funcall.FALSE;
else
return Funcall.TRUE;
}
-- Dan
Dan Larner, [EMAIL PROTECTED]
Xerox PARC, 3333 Coyote Hill Rd., Palo Alto, CA, USA 94304
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
JESS: Run Rete Exception -- was: definstances & undefinstances -- Rete Exception
Larner, Dan <[EMAIL PROTECTED]> Fri, 29 Jan 1999 19:41:03 -0500
- Re: JESS: Run Rete Exception -- was:... Larner, Dan <[EMAIL PROTECTED]>
- Re: JESS: Run Rete Exception --... Ernest Friedman-Hill
