JESS: RE: Simple patterns, non initialized Java beans.

"Nguyen, Son" <[email protected]> Fri, 11 Mar 2011 13:14:48 -0500
Newsgroups gmane.comp.java.jess
Message-ID <14484_1299868028_p2BII7b9014608_433500A5BB71E0429667F320009F438B0AD89FDC@resmsg04.AME.ad.sag>
> Hi,
> 
Sorry, the previous mail was sent prematurely.

> There seems to be an issue with simple patterns and non initialized
> slots derived from Java Beans.
> 
> I have the following class and a clp:
> 
> public class Slots {
> 	private Short age;
> 	public Slots() {
> //		age = (short) 1;
> 	}
> 	public Short getAge() {
> 		return age;
> 	}
> 	public void setAge(Short age) {
> 		this.age = age;
> 	}	
> }
> 
> (import Slots)
> (deftemplate Slots
> (declare (from-class Slots)))
> 
> (defrule rule
>     (Slots { (age > 0)} )
> =>
>     (printout t "age must not be null" crlf)
> )
> 
> (bind ?sl (new Slots))
> (add ?sl)
> (run)
> 
> If the age member initialized, it runs fine. If it is not, Jess throws
> an exception.
> 
> Jess reported an error in routine >
> 	while executing (> ?__synth0(0,0,-1) 0)
> 	while executing rule LHS (TEQ)
> 	while executing rule LHS (TECT)
> 	while executing (add ?sl).
>   Message: compareTo threw an exception.
>   Program text: ( add ?sl )  at line 12 in file D:\temp\slot.clp.
> 
> Nested exception is:
> java.lang.Integer cannot be cast to java.lang.String
> 
> Shouldn't Jess fail the test when the slot is not initialized?
> 
> Son Nguyen
>