Announcement Announcement Module
Collapse
No announcement yet.
spring 1.2.7 +Hibernate 3.0.5 ropertyNotFoundException: Could not find a getter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring 1.2.7 +Hibernate 3.0.5 ropertyNotFoundException: Could not find a getter

    Hai all,
    I develop application using spring 1.2.7 , jdk 1.5, tomcat 5.5.15, and Hibernate 3.0.5.
    When deploying classes that have many-to-many relationship on tomcat, I keep getting error:
    org.hibernate.PropertyNotFoundException: Could not find a getter for organizations in class model.ChartOfAccount,
    although the getter and setter are obviously exist.
    But this error is not appear on the test case using org.springframework.test.AbstractTransactionalData SourceSpringContextTests.
    Could someone kindly help me.

    Belows are the error stack, classes and hibernate mapping.
    Thanks in advance for your help.

    <====Error Stack ===>
    006-03-06 14:55:31,634 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/siriusAccounting-data.xml]: Initialization of bean failed; nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for organizations in class model.ChartOfAccount
    org.hibernate.PropertyNotFoundException: Could not find a getter for organizations in class model.ChartOfAccount
    at org.hibernate.property.BasicPropertyAccessor.creat eGetter(BasicPropertyAccessor.java:213)
    at org.hibernate.property.BasicPropertyAccessor.getGe tter(BasicPropertyAccessor.java:207)
    at org.hibernate.mapping.Property.getGetter(Property. java:240)
    at org.hibernate.tuple.PojoTuplizer.buildPropertyGett er(PojoTuplizer.java:237)
    at org.hibernate.tuple.AbstractTuplizer.<init>(Abstra ctTuplizer.java:73)
    at org.hibernate.tuple.PojoTuplizer.<init>(PojoTupliz er.java:54)
    at org.hibernate.tuple.TuplizerLookup.create(Tuplizer Lookup.java:47)
    at ...


    <===== Chart Of Account class ===>

    package model;

    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.HashSet;
    import java.util.List;
    import java.util.Set;

    public class ChartOfAccount implements Serializable{


    private static final long serialVersionUID = 7601506566284602484L;
    private Integer id;
    private String coaID;
    private String name;
    private String description;
    private Set glAccounts = new HashSet();
    private Set organizations;




    public String toString() {
    return "id"+id+",coaID:"+coaID+",name:"+name;
    }

    public String getCoaID() {
    return coaID;
    }


    public void setCoaID(String coaID) {
    this.coaID = coaID;
    }


    public String getDescription() {
    return description;
    }


    public void setDescription(String description) {
    this.description = description;
    }


    public Integer getId() {
    return id;
    }

    public void setId(Integer id) {
    this.id = id;
    }

    public String getName() {
    return name;
    }


    public void setName(String name) {
    this.name = name;
    }

    public Set getGlAccounts() {
    return glAccounts;
    }


    public void setGlAccounts(Set glAccounts) {
    this.glAccounts = glAccounts;
    }

    public void addGlAccount(GLAccount glAccount){
    glAccount.setCoa(this);
    glAccounts.add(glAccount);
    }



    public Set getOrganizations() {
    if(this.organizations == null){
    this.organizations=new HashSet();
    }
    return this.organizations;
    }

    public void setOrganizations(Set organizations) {
    this.organizations = organizations;
    }

    public void addOrganization(Organization organization){
    organization.getChartOfAccounts().add(this);
    organizations.add(organization);
    }



    }



    <==== Chart of Account Mapping ===>

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

    <hibernate-mapping

    >

    <class
    name="model.ChartOfAccount"
    table="chart_of_account"
    >

    <id
    name="id"
    column="id"
    type="integer"
    >

    <generator
    class="native"
    >

    </generator>

    </id>

    <property
    name="coaID"
    type="string"
    column="coa_id"
    length="50"
    >

    </property>

    <property
    name="description"
    type="string"
    column="description"
    length="300"
    >

    </property>

    <property
    name="name"
    type="string"
    column="name"
    length="50"
    >

    </property>

    <set
    name="glAccounts"
    table="glaccount"
    inverse="true"
    cascade="all-delete-orphan"
    order-by="account_number asc"
    >

    <key
    column="fk_coa"
    >

    </key>

    <one-to-many
    class="model.GLAccount"
    />

    </set>

    <set
    name="organizations"
    table="coa_organization"
    lazy="true"
    cascade="save-update"
    >

    <key
    column="coa_id"
    >

    </key>

    <many-to-many
    class="model.Organization"
    column="organization_id"
    >

    </many-to-many>

    </set>

    </class>

    </hibernate-mapping>





    <===== Organization class ===>
    package model;

    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.HashSet;
    import java.util.List;
    import java.util.Set;

    public class Organization implements Serializable{

    private static final long serialVersionUID = 651560668855945216L;
    private Integer id;
    private String name;
    private Set chartOfAccounts = new HashSet();
    private String organizationCode;





    public String toString() {
    return "id: "+id+"; name: "+name+"; Organization code: "+organizationCode;
    }




    public Integer getId() {
    return id;
    }



    public void setId(Integer id) {
    this.id = id;
    }




    public Set getChartOfAccounts() {
    return chartOfAccounts;
    }




    public void setChartOfAccounts(Set chartOfAccounts) {
    this.chartOfAccounts = chartOfAccounts;
    }

    public void addChartOfAccounts(ChartOfAccount coa){
    coa.getOrganizations().add(this);
    chartOfAccounts.add(coa);
    }




    public String getName() {
    return name;
    }



    public void setName(String name) {
    this.name = name;
    }




    public String getOrganizationCode() {
    return organizationCode;
    }


    public void setOrganizationCode(String organizationCode) {
    this.organizationCode = organizationCode;
    }


    }


    <===== Organization mapping ===>
    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

    <hibernate-mapping

    >

    <class
    name="model.Organization"
    table="organization"
    >

    <id
    name="id"
    column="organization_id"
    type="integer"
    >

    <generator
    class="native"
    >

    </generator>

    </id>

    <set
    name="chartOfAccounts"
    table="coa_organization"
    lazy="true"
    cascade="save-update"
    >

    <key
    column="organization_id"
    >

    </key>

    <many-to-many
    class="model.ChartOfAccount"
    column="coa_id"
    >

    </many-to-many>

    </set>

    <property
    name="name"
    type="string"
    column="name"
    >

    </property>

    <property
    name="organizationCode"
    type="string"
    column="organization_code"
    >

    </property>

    </class>

    </hibernate-mapping>

  • #2
    You should check your deployment environment: I suspect the classes deployed in tomcat differ from the ones used by your test case. This has several causes - some cache (usually happens in MyEclipse) gets in the way, tomcat doesn't redeploy the application or your packaging fails.
    Do a cleanup, see that it works and make sure you do a proper update.

    Comment


    • #3
      Hai Costin,
      Many thanks for your reply.
      You are right, the war file my ant deploy is corrupt.
      It was not the spring nor hibernate issue.
      BTW, Thank you for your help.

      regards,

      mailindra

      Comment

      Working...
      X