Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Bean property 'xx' is not writable or has an invalid setter?

  1. #1
    Join Date
    Apr 2005
    Posts
    9

    Default Bean property 'xx' is not writable or has an invalid setter?

    Hi,

    can somebody tell me what this means. I'm trying to figure out where to look for the mistake (applicationContext.xml?, model-class?, mapping-file?, ???).

    The error:
    org.springframework.beans.NotWritablePropertyExept ion: Invalid property 'myBean' of bean class .... :
    Bean property 'myBean' is not writable or has an invalid setter method: Does the parametertype of the setter match the return type of the getter?

    Any help/suggestions truly appreciated.

    Thanks
    Jonny

  2. #2
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    Well what does your setter look like?
    --Jing Xue

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Normally your setter and getter should address the same type, i.e.:

    Code:
    SomeClass myBean;
    
    public SomeClass getMyBean() { ... };
    public void setMyBean(SomeClass otherBean) { ... };
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4
    Join Date
    Apr 2005
    Posts
    9

    Default

    Hi,

    somehow I don't get this error. My POJO seems to be alright.

    The class:
    Code:
    package de.fhkempten.webedi.cocoon.portal.model.sap;
    
    
    /**
     * Sairport generated by hbm2java
     */
    public class Sairport  implements java.io.Serializable {
    
        // Fields    
    
     private java.lang.String Id;
     private java.lang.String Name;
     private java.lang.String City;
     private java.lang.String Country;
     private java.lang.String Utc;
    
    
        // Constructors
    
        /** default constructor */
        public Sairport() {
        }
        
        /** constructor with id */
        public Sairport(java.lang.String Id) {
            this.Id = Id;
        }
       
        // Property accessors
        /**
        
        */
        
        public java.lang.String getId () {
            return this.Id;
        }
        
       public void setId (java.lang.String Id) {
            this.Id = Id;
        }
        /**
        
        */
        
        public java.lang.String getName () {
            return this.Name;
        }
        
       public void setName (java.lang.String Name) {
            this.Name = Name;
        }
        /**
        
        */
        
        public java.lang.String getCity () {
            return this.City;
        }
        
       public void setCity (java.lang.String City) {
            this.City = City;
        }
        /**
        
        */
        
        public java.lang.String getCountry () {
            return this.Country;
        }
        
       public void setCountry (java.lang.String Country) {
            this.Country = Country;
        }
     /**
        
        */
        
        public java.lang.String getUtc () {
            return this.Utc;
        }
        
       public void setUtc (java.lang.String Utc) {
            this.Utc = Utc;
        }
    
    }


    The error:
    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'petStoreServiceTarget' defined in class path resource [de/fhkempten/webedi/cocoon/portal/spring/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sairportDAO' of bean class [de.fhkempten.webedi.cocoon.portal.spring.service.PetStoreServiceImpl]: Bean property 'sairportDAO' 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.NotWritablePropertyException: Invalid property 'sairportDAO' of bean class [de.fhkempten.webedi.cocoon.portal.spring.service.PetStoreServiceImpl]: Bean property 'sairportDAO' is not writable or has an invalid setter method: Does the parameter type of the setter match the re
    Or did I understand you guys wrong, that the error was probably in the POJO?

    Thanks
    Jonny

  5. #5
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    You posted the wrong class. The error is caused by the fact that you are trying to wire the property sairportDAO on class PetStoreServiceImpl which does not has such a property.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  6. #6
    Join Date
    Apr 2005
    Posts
    9

    Default

    Hi,

    thanks to all for your help. I was looking for the eror in the POJO class all the time. I totally forgot the setter for my bean in PetStoreServiceImpl. Now it works fine.

    Cheers
    Jonny

  7. #7

    Default

    Hi,

    I have a similar issue but it doesn't have anything to do with any of my class. I upgraded from 2.5 to 2.5.6 and I get this error on an application that used to work just fine.

    Any thoughts?

    Code:
    SEVERE: StandardWrapper.Throwable
    org.springframework.beans.factory.BeanCreationException: Error creating 
    bean with name 'org.springframework.context.annotation.internalPersistenceAnnotationProcessor': 
    Error setting property values; nested exception is 
    org.springframework.beans.NotWritablePropertyException: Invalid property 
    'order' of bean class 
    [org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor]: 
    Bean property 'order' is not writable or has an invalid setter method. Does 
    the parameter type of the setter match the return type of the getter?
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)

  8. #8
    Join Date
    Jun 2009
    Posts
    3

    Default

    thusi02, I have a similar issue to yours . . . did you ever find a resolution?

  9. #9
    Join Date
    Dec 2009
    Posts
    1

    Lightbulb

    you forget setter and getter in your service for dao object

  10. #10
    Join Date
    Jun 2009
    Posts
    190

    Default

    Same issue will be faced incase your setter method is static. I faced the same issue and found the setter was static.

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •