Look closely at your stack trace: it says "Message: Called method threw an exception." If you called getCause() on the JessException, it would return a NullPointerException, and if you looked at that NPE's stack trace, you'd see it was thrown by the getA() method of your Test class. Here are the relevant lines from your code:

private Integer a = null;
...
public int getA() {
  return a;
}

Note that the type of variable "a" is Integer, but getA() is returning an int. That means that, due to auto-unboxing, the Java compiler is going to emit code as if you had written something like

public int getA() {
    return a.intValue();
}


and since "a" is null, this line throws a NullPointerException. It's not Jess's fault if your getter methods throw NPEs when called!





On Aug 3, 2007, at 2:51 PM, Skeptic 2000 wrote:


Hi and thanks a lot for helping, the details are here :

That's the ShadowFact :

public class Test {




private Integer a = null;

private Integer b = 4;




public Test() {



}




public int getA() {

  return a;

}




public int getB() {

  return b;

}


}

That's the .CLP file :

(defclass Test xxx.yyy.zzz.Test)


(defrule testrule

(Test (a ?a) (b ?b))

=>

(printout t "testrule ok")

)

That's the java code :

void functionX() {
...
jessEngine.add(new Test());
...
}

That's the exception :

Jess reported an error in routine DefinstanceList.updateMultipleSlots.

Message: Called method threw an exception.

at jess.DefinstanceList.getSlotValueFromObject(DefinstanceList.java: 371)

at jess.DefinstanceList.setAllSlotValuesFromObject (DefinstanceList.java:353)

at jess.DefinstanceList.createNewShadowFact(DefinstanceList.java:332)

at jess.DefinstanceList.definstance(DefinstanceList.java:111)

at jess.Rete.definstance(Rete.java:1903)

at jess.Rete.definstance(Rete.java:1883)

at jess.Rete.add(Rete.java:2023)
...


JFL





> From: [EMAIL PROTECTED]
> Subject: Re: JESS: dealing with shadow facts having null properties
> Date: Fri, 3 Aug 2007 10:48:15 -0400
> To: jess-users@sandia.gov
>
> I can't reproduce anything like this; can you show me a stack trace
> (run jess.Main with -stacktrace to see a full error trace).
>
> On Aug 2, 2007, at 6:12 PM, Skeptic 2000 wrote:
>
> >
> > When I add a shadow fact with a property having a null value, I get
> > an exception (in updateMultiSlot IRRC).
> >
> > JFL
> >
> > > From: [EMAIL PROTECTED]
> > > Subject: Re: JESS: dealing with shadow facts having null properties
> > > Date: Thu, 2 Aug 2007 15:57:55 -0400
> > > To: jess-users@sandia.gov
> > >
> > > Jess has been able to handle null properties for a long time; 6.1p8 > > > can handle them, as can the current versions. What problem are you
> > > having, exactly?
> > >
> > > On Aug 2, 2007, at 2:19 PM, Skeptic 2000 wrote:
> > >
> > > >
> > > > Hi,
> > > >
> > > > I need to add in the working memory some shadow facts with
> > > > properties whose values are null. Currently, my workaround is to > > > > use a "NullObject" to prevent Jess from crashing upon finding a
> > > > null value.
> > > >
> > > > Is it the recommended way to do it ?
> > > >
> > > > JFL
> > > >
> > > > Soyez parmi les premiers à essayer Windows Live Mail.
> > >
> > > ---------------------------------------------------------
> > > Ernest Friedman-Hill
> > > Advanced Software Research Phone: (925) 294-2154
> > > Sandia National Labs FAX: (925) 294-2234
> > > PO Box 969, MS 9012 [EMAIL PROTECTED]
> > > Livermore, CA 94550 http://www.jessrules.com
> > >
> > > --------------------------------------------------------------------
> > > To unsubscribe, send the words 'unsubscribe jess-users
> > [EMAIL PROTECTED]'
> > > in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> > > (use your own address!) List problems? Notify owner-jess-
> > [EMAIL PROTECTED]
> > > --------------------------------------------------------------------
> > >
> >
> >
> > Soyez parmi les premiers à essayer Windows Live Mail.
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Advanced Software Research Phone: (925) 294-2154
> Sandia National Labs FAX: (925) 294-2234
> PO Box 969, MS 9012 [EMAIL PROTECTED]
> Livermore, CA 94550 http://www.jessrules.com
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify owner-jess- [EMAIL PROTECTED]
> --------------------------------------------------------------------
>


Soyez parmi les premiers à essayer Windows Live Mail.

---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550                 http://www.jessrules.com

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to