Announcement Announcement Module
Collapse
No announcement yet.
Bean property 'xx' is not writable or has an invalid setter? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Well what does your setter look like?

    Comment


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

      Code:
      SomeClass myBean;
      
      public SomeClass getMyBean() { ... };
      public void setMyBean(SomeClass otherBean) { ... };

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Comment


          • #6
            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

            Comment


            • #7
              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)

              Comment


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

                Comment


                • #9
                  you forget setter and getter in your service for dao object

                  Comment


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

                    Comment


                    • #11
                      I had the same problem when migrating Spring to a new Version. Look for stray JAR-files from old versions. In my case it was a dependency introduced by jaxws-spring through maven

                      Comment


                      • #12
                        Similar error

                        Following is the validatior I am using :

                        <bean id="validator"
                        class="org.springframework.batch.item.validator.Sp ringValidator">
                        <property name="billingTransactionId">
                        <bean id="luhnValidator" class="org.springmodules.validation.valang.ValangV alidator">
                        <property name="valang">
                        <value>
                        <![CDATA[{ billingTransactionId : ? < 33 : 'billingTransactionId field must be a grater that 33 number' } ]]>
                        </value>
                        </property>
                        </bean>
                        </property>
                        </bean>


                        I am getting error :
                        org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'compositeItemProcessor' defined in class path resource [MedJobValidation.xml]: Cannot resolve reference to bean 'validatingItemProcessor' while setting bean property 'itemProcessors' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'validatingItemProcessor' defined in class path resource [MedJobValidation.xml]: Cannot resolve reference to bean 'validator' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'validator' defined in class path resource [MedJobValidation.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'billingTransactionId' of bean class [org.springframework.batch.item.validator.SpringVal idator]: Bean property 'billingTransactionId' 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.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:275)


                        What is causing the error ?

                        Comment


                        • #13
                          Hi,

                          Could you please help somebody for this issue?

                          I am getting the following exception when I run the TestCases using Maven. Actually we have migrated from

                          Spring 2.5.4 to Spring 3.0.6
                          hibernate 3.1.3 to Hibernate 3.6.6.

                          Exception Log:
                          16976 [main] ERROR org.springframework.test.context.TestContextManage r - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener@4cbcaf] to prepare test instance [com.xxx.yyy.zzz.common.dao.hibernate.Activa tionCodeDAOTest@183698f]
                          java.lang.IllegalStateException: Failed to load ApplicationContext
                          at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:308)
                          at org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener.injectDependencies (DependencyInjectionTestExecutionListener.java:109 )
                          at org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener.prepareTestInstanc e(DependencyInjectionTestExecutionListener.java:75 )
                          at org.springframework.test.context.TestContextManage r.prepareTestInstance(TestContextManager.java:321)
                          at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.createTest(SpringJUnit4ClassRunner.j ava:211)
                          at org.springframework.test.context.junit4.SpringJUni t4ClassRunner$1.runReflectiveCall(SpringJUnit4Clas sRunner.java:287)
                          at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
                          at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.methodBlock(SpringJUnit4ClassRunner. java:289)
                          at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:231)
                          at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:50)
                          at org.junit.runners.ParentRunner$3.run(ParentRunner. java:193)
                          at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:52)
                          at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:191)
                          at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:42)
                          at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:184)
                          at org.junit.internal.runners.statements.RunBefores.e valuate(RunBefores.java:28)
                          at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
                          at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:70)
                          at org.junit.runners.ParentRunner.run(ParentRunner.ja va:236)
                          at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:174 )
                          at org.apache.maven.surefire.junit4.JUnit4TestSet.exe cute(JUnit4TestSet.java:62)
                          at org.apache.maven.surefire.suite.AbstractDirectoryT estSuite.executeTestSet(AbstractDirectoryTestSuite .java:140)
                          at org.apache.maven.surefire.suite.AbstractDirectoryT estSuite.execute(AbstractDirectoryTestSuite.java:1 27)
                          at org.apache.maven.surefire.Surefire.run(Surefire.ja va:177)
                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
                          at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
                          at java.lang.reflect.Method.invoke(Method.java:597)
                          at org.apache.maven.surefire.booter.SurefireBooter.ru nSuitesInProcess(SurefireBooter.java:345)
                          at org.apache.maven.surefire.booter.SurefireBooter.ma in(SurefireBooter.java:1009)
                          Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.transaction.interceptor.Trans actionInterceptor#0': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'transactionManagerBeanName' of bean class [org.springframework.transaction.interceptor.Transa ctionInterceptor]: Bean property 'transactionManagerBeanName' 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.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1361)
                          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1086)
                          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:517)
                          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
                          at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 93)
                          at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
                          at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:290 )
                          at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:192)
                          at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:585)
                          at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
                          at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
                          at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:84)
                          at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:1)
                          at org.springframework.test.context.TestContext.loadA pplicationContext(TestContext.java:280)
                          at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:304)
                          ... 29 more
                          Caused by: org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'transactionManagerBeanName' of bean class [org.springframework.transaction.interceptor.Transa ctionInterceptor]: Bean property 'transactionManagerBeanName' 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.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:1052)
                          at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:921)
                          at org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractPropertyAccessor.java:7 6)
                          at org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractPropertyAccessor.java:5 8)
                          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1358)
                          ... 43 more

                          configuration:
                          ------------------
                          spring-transaction.xml
                          <!-- Turn on annotation based transactions -->
                          <tx:annotation-driven />

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

                          spring-xxx-tests.xml
                          -----------------------
                          <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
                          <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
                          <property name="url" value="jdbc:oracle:thin:@//xxx:yyy/zzzz"/>
                          <property name="username" value="xxxx" />
                          <property name="password" value="yyyy" />
                          <property name="defaultTransactionIsolation" value="2"/>
                          </bean>

                          <bean id="systemDAO"
                          class="com.test.common.dao.hibernate.impl.TestSyst emDAOImpl">
                          <property name="sessionFactory" ref="sessionFactory" />
                          <property name="databasePropertyPlaceholderConfigurer" ref="databasePropertyPlaceholderConfigurer"/>
                          </bean>

                          <!-- Beans listed here don't override but are specific to tests. -->
                          <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
                          <property name="dataSource" ref="dataSource" />
                          </bean>
                          Last edited by chaatna; Jan 10th, 2012, 10:46 PM.

                          Comment


                          • #14
                            This is definitely a problem with incompatible jar versions. Check if you have changed all the spring jar versions to the latest (i.e. spring-orm)

                            Please use tags when you post code

                            Comment


                            • #15
                              Hi Amingo,

                              I am using same version of spring jars for spring-orm also. Please find the same:

                              <dependency>
                              <groupId>org.springframework</groupId>
                              <artifactId>spring-context-support</artifactId>
                              <version>${spring.version}</version>
                              </dependency>
                              <dependency>
                              <groupId>org.springframework</groupId>
                              <artifactId>spring-orm</artifactId>
                              <version>${spring.version}</version>
                              </dependency>
                              <dependency>
                              <groupId>org.springframework</groupId>
                              <artifactId>spring-oxm</artifactId>
                              <version>${spring.version}</version>
                              </dependency>
                              <dependency>
                              <groupId>org.springframework</groupId>
                              <artifactId>spring-core</artifactId>
                              <version>${spring.version}</version>
                              </dependency>
                              <dependency>
                              <groupId>org.springframework</groupId>
                              <artifactId>spring-test</artifactId>
                              <version>${spring.version}</version>
                              <scope>test</scope>
                              </dependency>
                              do we need to really configure "org.springframework.transaction.interceptor.Trans actionProxyFactoryBean"?

                              Thanks in advance.
                              Chaatna

                              Comment

                              Working...
                              X