Typically slots come from JavaBeans properties, not fields – i.e., accessor 
methods like getEventID(). But if you specify “include-variables” when you 
create a deftemplate from a class, then public (and only public!) member fields 
will be used as well. See  
http://www.jessrules.com/jess/docs/71/memory.html#shadow_facts  .

From: owner-jess-us...@sandia.gov [mailto:owner-jess-us...@sandia.gov] On 
Behalf Of Tom De Costere
Sent: Tuesday, May 21, 2013 6:24 AM
To: jess-users
Subject: JESS: [EXTERNAL] Usage of abstract classes in rules


I currently have some abstract classes which are then implemented in various 
other classes extending those abstract classes. Now I’ve been trying to get 
Jess to work with both the abstract class as the implementation class, but 
somehow Jess cannot reach to the fields/methods specified in the abstract 

Is this normal functionality of Jess or must I make such a conversion object 
that contains both the fields from the abstract class as the fields from the 
implementation class?


My abstract class AbstractApplicationEvent contains following protected fields:
- eventID
- eventName
- eventTimestamp

My subclass ConnectionMadeEvent extending the abstract class above no extra 
fields, but can be extended in the future.


(defrule connection_established
    (declare (salience 50))
    ?f1 <- (ConnectionMadeEvent (eventID ?id) (eventTimestamp ?eventTimestamp))
    (assert (Notification (icon "ICON_CONNECTION_ACTIVE") (generationTime 
?eventTimestamp) (event ?f1)))

Error message:

SEVERE: Error loading Ruleset from: rules/global_rules.clp
Jess reported an error in routine Jesp.parsePattern.
  Message: No such slot eventTimestamp in template MAIN::ConnectionMadeEvent at 
token 'eventTimestamp'.
  Program text: ( defrule connection_established ( declare ( salience 50 ) ) 
?f1 <- ( ConnectionMadeEvent ( eventID ?id ) ( eventTimestamp  at line 110 in 
file rules/global_rules.clp.

Thanks in advance!

Tom DC

Reply via email to