I guess one of the Attributes in IndividualNok has no getter / setter method.

 

Just verify

 


From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Jian Li
Sent: Monday, June 18, 2007 8:41 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] NullPointerException: org.drools.base.extractors.BaseObjectClassFieldExtractor.getLongValue(BaseObjectClassFieldExtractor.java:103)

 

Hi,

 

The following problem encountered:

 

I have a rule defintion :

 

----------------------------------------------dpd.drl

package ruletest;

import ruletest.IndividualNok;


rule Female_NOK_sex_401
   //when (IndividualNok(nokRelationship==401) || IndividualNok(nokRelationship==402))
   when (IndividualNok(nokRelationship==401) || IndividualNok(nokRelationship==402) || IndividualNok(nokRelationship==403))
   then
       System.out.println("abc");
   end

------------------------------------------------

 

 

When I tried the commented out LSH, it works, however, when i add one more expression to it , it fails with the following exceptions:

 

Exception in thread "main" java.lang.NullPointerException
        at org.drools.base.extractors.BaseObjectClassFieldExtractor.getLongValue(BaseObjectClassFieldExtractor.java:103)
        at org.drools.base.ClassFieldExtractor.getLongValue(ClassFieldExtractor.java:144)
        at org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.setValue(CompositeObjectSinkAdapter.java:467)
        at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:292)
        at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:183)
        at org.drools.reteoo.Rete.assertObject(Rete.java:121)
        at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:201)
        at org.drools.reteoo.ReteooWorkingMemory.doAssertObject(ReteooWorkingMemory.java:70)
        at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:724)
        at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:548)

Any idea about this? is it a bug

 

When I tried to create an additional rule with the 2 expression, it still fails. This error can be reproduced with the followng code:

 

-------------------------the Main Class's main method

    public static void main(String[] args) {
        // TODO code application logic here
               final PackageBuilder builder = new PackageBuilder();
        try {
            builder.addPackageFromDrl( new InputStreamReader( Main.class.getResourceAsStream( "dpd.drl" ) ) );
        } catch (DroolsParserException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
       
        final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
        try {
            ruleBase.addPackage( builder.getPackage() );
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        final StatefulSession session = ruleBase.newStatefulSession();
        IndividualNok individualNok = new IndividualNok();
        session.assertObject(individualNok);
        session.fireAllRules();
        session.dispose();
    }

-------------------------------------------------

-------------------------------------------------Person class: requried by individualNok, a simple POJO

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author Jian.Li
 */
public class Person implements java.io.Serializable {
   
    // Fields
   
    private Long personId;
    private Integer nationality;
    private Integer race;
    private String firstName;
    private String lastName;
    private String midName;
    private Date birthdate;
    private Integer occupation;
    private Integer religion;
    private Integer primaryLanguage;
    private Integer veteransStatus;
    private String idNo;
    private Integer idType;
    private String mobileNo;
    private String email;
    private Integer ethnicgroupcountry;
    private Integer ethnicgroupstate;
    private Integer ethnicgroupcity;
    private Integer sex;
    private Integer maritalStatus;
    private Date lud;
    private String lub;
    private Set individualNoksForNokPersonId = new HashSet(0);
    private Set careproviders = new HashSet(0);
    private Set residentialAddresses = new HashSet(0);
    private Set individualNoksForPersonId = new HashSet(0);
   
    // Constructors
    /** default constructor */
    public Person() {
    }
    /** minimal constructor */
    public Person(String firstName, String lastName, Date birthdate,
            Integer sex, Integer maritalStatus, Date lud) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.birthdate = birthdate;
        this.sex = sex;
        this.maritalStatus = maritalStatus;
        this.lud = lud;
    }
   
    /** full constructor */
    public Person(Integer nationality, Integer race, String firstName,
            String lastName, String midName, Date birthdate,
            Integer occupation, Integer religion, Integer primaryLanguage,
            Integer veteransStatus, String idNo, Integer idType,
            String mobileNo, String email, Integer ethnicgroupcountry,
            Integer ethnicgroupstate, Integer ethnicgroupcity, Integer sex,
            Integer maritalStatus, Date lud, String lub,
            Set individualNoksForNokPersonId, Set careproviders,
            Set residentialAddresses, Set individualNoksForPersonId) {
        this.nationality = nationality;
        this.race = race;
        this.firstName = firstName;
        this.lastName = lastName;
        this.midName = midName;
        this.birthdate = birthdate;
        this.occupation = occupation;
        this.religion = religion;
        this.primaryLanguage = primaryLanguage;
        this.veteransStatus = veteransStatus;
        this.idNo = idNo;
        this.idType = idType;
        this.mobileNo = mobileNo;
        this.email = email;
        this.ethnicgroupcountry = ethnicgroupcountry;
        this.ethnicgroupstate = ethnicgroupstate;
        this.ethnicgroupcity = ethnicgroupcity;
        this.sex = sex;
        this.maritalStatus = maritalStatus;
        this.lud = lud;
        this.lub = lub;
        this.individualNoksForNokPersonId = individualNoksForNokPersonId;
        this.careproviders = careproviders;
        this.residentialAddresses = residentialAddresses;
        this.individualNoksForPersonId = individualNoksForPersonId;
    }
   
    // Property accessors
    public Long getPersonId() {
        return this.personId;
    }
    public void setPersonId(Long personId) {
        this.personId = personId;
    }
    public Integer getNationality() {
        return this.nationality;
    }
    public void setNationality(Integer nationality) {
        this.nationality = nationality;
    }
    public Integer getRace() {
        return this.race;
    }
    public void setRace(Integer race) {
        this.race = race;
    }
    public String getFirstName() {
        return this.firstName;
    }
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    public String getLastName() {
        return this.lastName;
    }
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
    public String getMidName() {
        return this.midName;
    }
    public void setMidName(String midName) {
        this.midName = midName;
    }
    public Date getBirthdate() {
        return this.birthdate;
    }
    public void setBirthdate(Date birthdate) {
        this.birthdate = birthdate;
    }
    public Integer getOccupation() {
        return this.occupation;
    }
    public void setOccupation(Integer occupation) {
        this.occupation = occupation;
    }
    public Integer getReligion() {
        return this.religion;
    }
    public void setReligion(Integer religion) {
        this.religion = religion;
    }
    public Integer getPrimaryLanguage() {
        return this.primaryLanguage;
    }
    public void setPrimaryLanguage(Integer primaryLanguage) {
        this.primaryLanguage = primaryLanguage;
    }
    public Integer getVeteransStatus() {
        return this.veteransStatus;
    }
    public void setVeteransStatus(Integer veteransStatus) {
        this.veteransStatus = veteransStatus;
    }
    public String getIdNo() {
        return this.idNo;
    }
    public void setIdNo(String idNo) {
        this.idNo = idNo;
    }
    public Integer getIdType() {
        return this.idType;
    }
    public void setIdType(Integer idType) {
        this.idType = idType;
    }
    public String getMobileNo() {
        return this.mobileNo;
    }
    public void setMobileNo(String mobileNo) {
        this.mobileNo = mobileNo;
    }
    public String getEmail() {
        return this.email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public Integer getEthnicgroupcountry() {
        return this.ethnicgroupcountry;
    }
    public void setEthnicgroupcountry(Integer ethnicgroupcountry) {
        this.ethnicgroupcountry = ethnicgroupcountry;
    }
    public Integer getEthnicgroupstate() {
        return this.ethnicgroupstate;
    }
    public void setEthnicgroupstate(Integer ethnicgroupstate) {
        this.ethnicgroupstate = ethnicgroupstate;
    }
    public Integer getEthnicgroupcity() {
        return this.ethnicgroupcity;
    }
    public void setEthnicgroupcity(Integer ethnicgroupcity) {
        this.ethnicgroupcity = ethnicgroupcity;
    }
    public Integer getSex() {
        return this.sex;
    }
    public void setSex(Integer sex) {
        this.sex = sex;
    }
    public Integer getMaritalStatus() {
        return this.maritalStatus;
    }
    public void setMaritalStatus(Integer maritalStatus) {
        this.maritalStatus = maritalStatus;
    }
    public Date getLud() {
        return this.lud;
    }
    public void setLud(Date lud) {
        this.lud = lud;
    }
    public String getLub() {
        return this.lub;
    }
    public void setLub(String lub) {
        this.lub = lub;
    }
    public Set getIndividualNoksForNokPersonId() {
        return this.individualNoksForNokPersonId;
    }
    public void setIndividualNoksForNokPersonId(Set individualNoksForNokPersonId) {
        this.individualNoksForNokPersonId = individualNoksForNokPersonId;
    }
    public Set getCareproviders() {
        return this.careproviders;
    }
    public void setCareproviders(Set careproviders) {
        this.careproviders = careproviders;
    }
    public Set getResidentialAddresses() {
        return this.residentialAddresses;
    }
    public void setResidentialAddresses(Set residentialAddresses) {
        this.residentialAddresses = residentialAddresses;
    }
    public Set getIndividualNoksForPersonId() {
        return this.individualNoksForPersonId;
    }
    public void setIndividualNoksForPersonId(Set individualNoksForPersonId) {
        this.individualNoksForPersonId = individualNoksForPersonId;
    }
}

----------------------------------------------------------------------------------------------------

-------------------------------------IndividualNok class : a simple POJO

public class IndividualNok implements java.io.Serializable {
   
    // Fields
   
    private Long individualNokId;
   
    private Person personByPersonId;
   
    private Person personByNokPersonId;
   
    private Integer nokRelationship;
   
    private Integer emgcycntctInd;
   
    // Constructors
   
    /** default constructor */
    public IndividualNok() {
    }
   
    /** minimal constructor */
    public IndividualNok(Integer nokRelationship) {
        this.nokRelationship = nokRelationship;
    }
   
    /** full constructor */
    public IndividualNok(Person personByPersonId, Person personByNokPersonId,
            Integer nokRelationship, Integer emgcycntctInd) {
        this.personByPersonId = personByPersonId;
        this.personByNokPersonId = personByNokPersonId;
        this.nokRelationship = nokRelationship;
        this.emgcycntctInd = emgcycntctInd;
    }
   
    // Property accessors
    public Long getIndividualNokId() {
        return this.individualNokId;
    }
   
    public void setIndividualNokId(Long individualNokId) {
        this.individualNokId = individualNokId;
    }
   
    public Person getPersonByPersonId() {
        return this.personByPersonId;
    }
   
    public void setPersonByPersonId(Person personByPersonId) {
        this.personByPersonId = personByPersonId;
    }
   
    public Person getPersonByNokPersonId() {
        return this.personByNokPersonId;
    }
   
    public void setPersonByNokPersonId(Person personByNokPersonId) {
        this.personByNokPersonId = personByNokPersonId;
    }
   
    public Integer getNokRelationship() {
        return this.nokRelationship;
    }
   
    public void setNokRelationship(Integer nokRelationship) {
        this.nokRelationship = nokRelationship;
    }
   
    public Integer getEmgcycntctInd() {
        return this.emgcycntctInd;
    }
   
    public void setEmgcycntctInd(Integer emgcycntctInd) {
        this.emgcycntctInd = emgcycntctInd;
    }
   
}

---------------------------------------End of IndividualNok

 

 


Yahoo! Movies - Search movie info and celeb profiles and photos.

Any comments or statements made in this email are not necessarily those of Tavant Technologies. The information transmitted is intended only for the 
person or entity to which it is addressed and may contain confidential and/or privileged material. If you have received this in error, please contact 
the sender and delete the material from any computer. All e-mails sent from or to Tavant Technologies. may be subject to our monitoring procedures.