Announcement Announcement Module
Collapse
No announcement yet.
Error setting property values - Getters and setters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error setting property values - Getters and setters

    I'm using Hibernate version 3 and when I try to deploy my application I get an error:

    11:43:12,843 WARN [jbossweb] org.springframework.beans.factory.BeanCreationExce
    ption: Error creating bean with name 'hibernateInterceptor' defined in ServletCo
    ntext resource [/WEB-INF/application-context.xml]: Error setting property values
    ; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: In
    valid property 'hibernateTemplate' of bean class [org.springframework.orm.hibern
    ate3.HibernateInterceptor]: Bean property 'hibernateTemplate' is not writable or
    has an invalid setter method: Does the parameter type of the setter match the r
    eturn type of the getter?
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
    h name 'hibernateInterceptor' defined in ServletContext resource [/WEB-INF/appli
    cation-context.xml]: Error setting property values; nested exception is org.spri
    ngframework.beans.NotWritablePropertyException: Invalid property 'hibernateTempl
    ate' of bean class [org.springframework.orm.hibernate3.HibernateInterc eptor]: Be
    an property 'hibernateTemplate' is not writable or has an invalid setter method:
    Does the parameter type of the setter match the return type of the getter?
    org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'hibern
    ateTemplate' of bean class [org.springframework.orm.hibernate3.HibernateInterc ep
    tor]: Bean property 'hibernateTemplate' is not writable or has an invalid setter
    method: Does the parameter type of the setter match the return type of the gett
    er?

    My mapping file:

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

    <hibernate-mapping>

    <class name="bus.Country" table="XMCTRY0">

    <id name="COUNTRY" column="ID" type="string">
    <generator class="increment"/>
    </id>

    <property name="ROOTNAME" column="RootName" type="string"/>
    <property name="DESCRIPTION" column="Description" type="string"/>
    <property name="SHORTDESCRIPTION" column="Short_Description" type="string"/>
    <property name="ECONOMICGROUP" column="Economic_Group" type="string"/>
    <property name="ECCNGROUP" column="Eccn_Group" type="string"/>
    <property name="IMPORTGROUP" column="Import_Group" type="string"/>
    <property name="EXPORTGROUP" column="Export_Group" type="string"/>
    <property name="DOMESTICINBOUNDGROUP" column="Domestic_Inbound_Group" type="string"/>
    <property name="DOMESTICOUTBOUNDGROUP" column="Domestic_Outbound_Group" type="string"/>
    <property name="VATPREFIXNUMBER" column="Vat_Prefix_Number" type="string"/>
    <property name="NATIONALITY" column="Nationality" type="string"/>
    <property name="ALTERNATIVECODE" column="Alternative_Code" type="string"/>
    <property name="MARKET" column="Market" type="string"/>
    <property name="DATEFORMAT" column="Date_Format" type="string"/>
    <property name="DECIMALFORMAT" column="Decimal_Format" type="string"/>
    <property name="ISOCODE" column="ISO_Code" type="string"/>
    <property name="ISONUMERICCODE" column="ISO_Numeric_Code" type="string"/>
    <property name="FORINTRASTATREPORTING" column="For_Intrastat_Reporting" type="string"/>
    <property name="ZONE" column="Zone" type="string"/>
    <property name="ZONEFORMAT" column="Zone_Format" type="string"/>
    <property name="POSTALCODEFORMAT" column="Postal_Code_Format" type="string"/>
    <property name="FOREIGNTRADEZONE" column="Foreign_Trade_Zone" type="string"/>
    <property name="PRIMARYLANGUAGEONDOCUMENTS" column="Primary_Language_On_Documents" type="string"/>
    <property name="ADDRESSLAYOUTTYPE" column="Address_Layout_Type" type="string"/>
    <property name="CHARGECLASS" column="Charge_Class" type="string"/>
    <property name="EUCLASSIFICATION" column="UE_Classification" type="string"/>
    <property name="REFUNDABLE" column="Refundable" type="string"/>
    <property name="USERDEFINED1" column="User_Defined_1" type="string"/>
    <property name="USERDEFINED2" column="User_Defined_2" type="string"/>
    <property name="USERDEFINED3" column="User_Defined_3" type="string"/>

    </class>

    </hibernate-mapping>

    The error is suggesting that my auto-generated java code is missing setters or getters, but its not as far as i can see, here's a snippet:

    /** default constructor */
    public Country() {
    }

    public String getCOUNTRY() {
    return this.COUNTRY;
    }

    public void setCOUNTRY(String COUNTRY) {
    this.COUNTRY = COUNTRY;
    }

    public String getROOTNAME() {
    return this.ROOTNAME;
    }

    public void setROOTNAME(String ROOTNAME) {
    this.ROOTNAME = ROOTNAME;
    }

    public String getDESCRIPTION() {
    return this.DESCRIPTION;
    }

    public void setDESCRIPTION(String DESCRIPTION) {
    this.DESCRIPTION = DESCRIPTION;
    }

    Any help would relally be appreciated

  • #2
    As specified in the stack trace :
    Code:
    Invalid property 'hibernateTemplate' of bean class &#91;org.springframework.orm.hibernate3.HibernateInterceptor&#93;&#58; Bean property 'hibernateTemplate' is not writable or has an invalid setter method&#58; Does the parameter type of the setter match the return type of the getter?
    You are trying to set the property "HibernateTemplate" onto the "HibernateInterceptor" class.

    Can you post your xml where the beans are wired together please

    Comment


    • #3
      I've changed my beans a bit to try and simply things but I'm stilkl getting the same error, this is the new stack trace and bean definition:

      10:07:36,852 WARN [jbossweb] org.springframework.beans.factory.BeanCreationExce
      ption: Error creating bean with name 'countryManDaoImpl' defined in ServletConte
      xt resource [/WEB-INF/application-context.xml]: Error setting property values; n
      ested exception is org.springframework.beans.NotWritablePropertyExcep tion: Inval
      id property 'hibTemplate' of bean class [db.CountryManagerDaoImpl]: Bean propert
      y 'hibTemplate' is not writable or has an invalid setter method: Does the parame
      ter type of the setter match the return type of the getter?
      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
      h name 'countryManDaoImpl' defined in ServletContext resource [/WEB-INF/applicat
      ion-context.xml]: Error setting property values; nested exception is org.springf
      ramework.beans.NotWritablePropertyException: Invalid property 'hibTemplate' of b
      ean class [db.CountryManagerDaoImpl]: Bean property 'hibTemplate' is not writabl
      e or has an invalid setter method: Does the parameter type of the setter match t
      he return type of the getter?
      org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'hibTem
      plate' of bean class [db.CountryManagerDaoImpl]: Bean property 'hibTemplate' is
      not writable or has an invalid setter method: Does the parameter type of the set
      ter match the return type of the getter?



      The application-context.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

      <!--
      - Application context definition for springhib using Hibernate.
      -->
      <beans>



      <!-- ========================= RESOURCE DEFINITIONS ========================= -->

      <!-- Configurer that replaces ${...} placeholders with values from a properties file -->
      <!-- (in this case, JDBC-related settings for the dataSource definition below) -->
      <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
      <property name="location" value="/WEB-INF/jdbc.properties"/>
      </bean>

      <!-- Local DataSource that works in any environment -->
      <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
      <property name="driverClassName" value="${jdbc.driverClassName}"/>
      <property name="url" value="${jdbc.url}"/>
      <property name="username" value="${jdbc.username}"/>
      <property name="password" value="${jdbc.password}"/>
      </bean>

      <!-- Hibernate SessionFactory -->
      <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
      <property name="dataSource" ref="dataSource"/>
      <property name="mappingResources">
      <value>bus/country.hbm.xml</value>
      </property>
      <property name="hibernateProperties">
      <props>
      <prop key="hibernate.dialect">${hibernate.dialect}</prop>
      <prop key="hibernate.show_sql">true</prop>
      <prop key="hibernate.generate_statistics">true</prop>
      </props>
      </property>
      <property name="eventListeners">
      <map>
      <entry key="merge">
      <bean class="org.springframework.orm.hibernate3.support. IdTransferringMergeEventListener"/>
      </entry>
      </map>
      </property>
      </bean>


      <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.Hibernat eTemplate">
      <property name="sessionFactory">
      <ref bean="sessionFactory"/>
      </property>
      </bean>

      <bean id="countryManDaoImpl" class="db.CountryManagerDaoImpl">
      <property name="hibTemplate">
      <ref bean="hibernateTemplate"/>
      </property>
      </bean>

      <bean id="countryMan" class="bus.CountryManager">
      <property name="countryManDaoImpl">
      <ref bean="countryManDaoImpl"/>
      </property>

      </bean>

      Hope you can help, thanks.

      Comment

      Working...
      X