Results 1 to 4 of 4

Thread: InvalidPropety on bean

  1. #1
    Join Date
    Sep 2004
    Location
    London
    Posts
    311

    Default InvalidPropety on bean

    hello all,
    i am banging my head against a NotWritablePropertyException in spring
    i have a spring-based webapplication in which i am defining a bean with two string propertiess..
    here is the code

    Code:
    public class DataSourcePopulator  {
    	//~ Instance fields       private DataSource dataSource;
          private int createEntities = 1000;
          private JdbcTemplate template = null;
    
    	  private String[] externalSqlFiles;
    	  private SqlScriptParser sqlScriptParser = new SqlScriptParser();
    
    
    	  private String seedFile="";
    
    
          //~ Methods ================================================================
    
          public void setCreateEntities(int createEntities) {
              this.createEntities = createEntities;
          }
    
          public int getCreateEntities() {
              return createEntities;
          }
    
          public void setDataSource(DataSource dataSource) {
              this.dataSource = dataSource;
          }
    
          public DataSource getDataSource() {
              return dataSource;
          }
    
    
          public void setExternalSqlFiles(String[] files) {
    		  externalSqlFiles = files;
      	  }
    
    
      	  public String[] getExternalSqlFiles() {
    		  return externalSqlFiles;
      	  }
    
    
    	  public void setSeedFile(String file) {
    		  seedFile = file;
    	  }
    
    	  public String getSeedFile() {
    		  return seedFile;
    	  }
       ....
    and following dataSourcePopulator.xml (which is being loaded at startup in jboss 4.0.2)

    Code:
    <beans>
    	<!-- Configurer that replaces ${...} placeholders with values from properties files -->
    	<!-- (in this case, mail and JDBC related properties) -->
    
          <bean id="dataSourcePopulator" 
    	           class="com.myapp.backend.util.DataSourcePopulator" init-method="init">
    	            
    	             <property  name="dataSource">
    	      		<ref bean="dataSource"/>
    	      	     </property>
    	      	     
    	      	     
    	      	     <property name="externalSqlFiles">
    	      	        <list>
    	      	           <value>Backend-1.0-schema.sql</value>
    	      	        </list>
    	      	     </property>
    	      	     
    	      	     <property  name="seedFile">
    		      	  <value>budget-seed.xml</value>
    		     </property>
    	      	     	      	     
    	      	     
             </bean>
        	      
          
    </beans>
    i think i need another pair of eyes that have a look at what my
    eyes refuse to see......

    anyone can help?

    i am usign spring 1.2.8 under JBoss 4.0.2

    thankx and regards
    marco

  2. #2
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    Please post your exception.

  3. #3
    Join Date
    Sep 2004
    Location
    London
    Posts
    311

    Default

    Hello,
    sorry for my omission...
    here's the exception
    Code:
    2005-11-15 16:20:56,460 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourcePopulator' defined in ServletContext resource [/WEB-INF/dataSourcePopulator.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'externalSqlFiles' of bean class [com.myapp.backend.util.DataSourcePopulator]: Bean property 'externalSqlFiles' 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 'externalSqlFiles' of bean class [com.myapp.backend.util.DataSourcePopulator]: Bean property 'externalSqlFiles' 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.setPropertyValue(BeanWrapperImpl.java:831)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:733)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:890)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:917)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:906)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1022)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:318)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3669)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4104)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    i can't understand why it is complaining about that property....
    it has a public setter and a public getter........

    and, a little mistake, i am using spring-1.2.1


    thanks in advance and regards
    marco

  4. #4
    Join Date
    Sep 2004
    Location
    London
    Posts
    311

    Default

    hello all,
    my fault sorry... i was loading the bean class from an old jar...

    thanks and regards
    marco

Posting Permissions

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