Announcement Announcement Module
Collapse
No announcement yet.
org.springframework.beans.NotWritablePropertyExcep tion Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • org.springframework.beans.NotWritablePropertyExcep tion

    Hello, i'm deepening into spring, and
    i'm following this tutorial:
    http://www.springframework.org/docs/...ep-Part-2.html

    I have this controller:

    Code:
    import java.util.HashMap;
    
    public class SpringappController implements Controller {
    
    	 /** Logger for this class and subclasses */
        protected final Log logger = LogFactory.getLog(getClass());
    
        private ArgomentoManager argomentoMananager;
    	
    	public ModelAndView handleRequest(HttpServletRequest arg0,
    			HttpServletResponse arg1) throws Exception {
    		
    		logger.info("SpringappController - returning hello view");
    
    		String now = (new java.util.Date()).toString(); 
    		
    		Map myModel = new HashMap();
            myModel.put("now", now);
            myModel.put("argomenti", getArgomentoMananager().getArgomenti());
    		
            return new ModelAndView("hello", "model", myModel);
    	}
    
    	public ArgomentoManager getArgomentoMananager() {
    		return argomentoMananager;
    	}
    
    	public void setArgomentoMananager(ArgomentoManager argMan) {
    		this.argomentoMananager = argMan;
    	}
    
    }
    ArgomentoManager is a bean like this:
    Code:
    public class ArgomentoManager implements Serializable {
    	
    	List argomenti;
    
    	public List getArgomenti() {
    		return argomenti;
    	}
    
    	public void setArgomenti(List argomento) {
    		this.argomenti = argomento;
    	}
    }
    and in springapp-servlet.xml I configured it like this:
    Code:
    <beans>
        <bean id="springappController" class="it.chi.repubblica.controller.SpringappController">
            <property name="argomentoManager">
                <ref bean="argMan"/>
            </property>
    	</bean>
    
    	<bean id="argMan" class="it.chi.repubblica.model.ArgomentoManager">
            <property name="argomenti">
                <list>
                    <ref bean="arg1"/>
                    <ref bean="arg2"/>
                    <ref bean="arg3"/>
                </list>
            </property>
        </bean>
    	
    	<bean id="arg1" class="it.chi.repubblica.model.Argomento">
    		<property name="nome"><value>TAV</value>
    		</property>	
    	</bean>
    
    	<bean id="arg2" class="it.chi.repubblica.model.Argomento">
    		<property name="nome"><value>quote rosa</value>
    		</property>	
    	</bean>
    
    	<bean id="arg3" class="it.chi.repubblica.model.Argomento">
    		<property name="nome"><value>elezioni</value>
    		</property>	
    	</bean>
            .....
    </beans>
    when I deploy the webapp into tomcat (5.5.15, linux) i get this stack trace:

    Code:
    14:52:17,568 ERROR DispatcherServlet:227 - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springappController' defined in ServletContext resource [/WEB-INF/springapp-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'argomentoManager' of bean class [it.chi.repubblica.controller.SpringappController]: Bean property 'argomentoManager' 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 'argomentoManager' of bean class [it.chi.repubblica.controller.SpringappController]: Bean property 'argomentoManager' 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:567)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:469)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:626)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:653)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:642)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1023)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:824)
    	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:320)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:305)
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:250)
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:219)
    	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:211)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3915)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4176)
    	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 org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:804)
    	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:497)
    	at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1195)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
    	at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
    	at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
    	at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1377)
    	at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:636)
    	at org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java:423)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:712)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    	at java.lang.Thread.run(Thread.java:595)
    (i had to shorten the exception, but relevant part is there)

    what am I doing wrong ?

    thanks,
    valerio

  • #2
    typo error

    i solved it my self...

    the controller declared :
    Code:
    private ArgomentoManager argomentoMananager
    but it had to be :

    Code:
    private ArgomentoManager argomentoManager
    according to the definition I wrote in the springapp-servlet.xml

    nevermind,

    valerio

    Comment

    Working...
    X