Announcement Announcement Module
Collapse
No announcement yet.
NotWritablePropertyException Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NotWritablePropertyException

    Hi friends!!
    I'm trying to use to DataSource on my application, that seems like that:

    Code:
    <!-- JNDI DataSource para entornos J2EE para el esquema ARS-->
    	<bean id="dataSourceArs" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName"><value>java&#58;comp/env/jdbc/ars</value></property>
    	</bean>
    	<!-- JNDI DataSource para entornos J2EE para el esquema MSMB-->
    	<bean id="dataSourceSmb" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName"><value>java&#58;comp/env/jdbc/smb</value></property>
    	</bean>
    	
    	<!-- SessionFactory de Hibernate para el esquema ARS-->
    	<bean id="sessionFactoryArs" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource"><ref local="dataSourceArs"/></property>
    		<!-- Fichero donde se encuentra el mapeo a los objetos relaciones en BBDD -->
    		<property name="mappingResources">
    			<value>com/acotelsa/smb2/smbweb/ars/hibernate/ars.hibernate.xml</value>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
                    <prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
                    <prop key="hibernate.show_sql">false</prop>
    			</props>
    		</property>
    	</bean>
    	<!-- SessionFactory de Hibernate para el esquema MSMB-->
    	<bean id="sessionFactorySmb" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource"><ref local="dataSourceSmb"/></property>
    		<!-- Fichero donde se encuentra el mapeo a los objetos relaciones en BBDD -->
    		<property name="mappingResources">
    			<value>com/acotelsa/smb2/smbweb/ars/hibernate/smb.hibernate.xml</value>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
                    <prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
                    <prop key="hibernate.show_sql">false</prop>
    			</props>
    		</property>
    	</bean>
    	
    	<!-- Manager de transacciones para el SessionFactory de Hibernate &#40;alternativo a JTA&#41; para el esquema ARS-->
    	<bean id="transactionManagerArs" class="org.springframework.orm.hibernate.HibernateTransactionManager">
    		<property name="sessionFactory"><ref local="sessionFactoryArs"/></property>
    	</bean>
    	<!-- Manager de transacciones para el SessionFactory de Hibernate &#40;alternativo a JTA&#41; para el esquema MSMB-->
    	<bean id="transactionManagerSmb" class="org.springframework.orm.hibernate.HibernateTransactionManager">
    		<property name="sessionFactory"><ref local="sessionFactorySmb"/></property>
    	</bean>
    	
    	<!-- ========================= DEFINICIONES DE OBJETOS DE NEGOCIO ========================= -->
    	<!-- Proxy transaccional para el objeto de negocio principal de la aplicacion para el esquema ARS-->
    	<bean id="arsManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager"><ref local="transactionManagerArs"/></property>
    		<property name="target"><ref bean="arsTarget"/></property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="add*">PROPAGATION_REQUIRED</prop>
    				<prop key="update*">PROPAGATION_REQUIRED</prop>
    				<prop key="delete*">PROPAGATION_REQUIRED</prop>
    				<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    				<prop key="exists*">PROPAGATION_REQUIRED,readOnly</prop>
    			</props>
    		</property>
    	</bean>
    	<!-- Proxy transaccional para el objeto de negocio principal de la aplicacion para el esquema MSMB-->
    	<bean id="smbManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager"><ref local="transactionManagerSmb"/></property>
    		<property name="target"><ref bean="smbTarget"/></property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="add*">PROPAGATION_REQUIRED</prop>
    				<prop key="update*">PROPAGATION_REQUIRED</prop>
    				<prop key="delete*">PROPAGATION_REQUIRED</prop>
    				<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    				<prop key="exists*">PROPAGATION_REQUIRED,readOnly</prop>
    			</props>
    		</property>
    	</bean>
    	
    	<!-- Objeto de negocio principal, manager principal, de Smbweb para el esquema ARS.Implementacion con Hibernate -->
    	<bean id="arsTarget" class="com.acotelsa.smb2.smbweb.ars.hibernate.HibernateDatabaseManagerArs">
    		<property name="sessionFactory"><ref bean="sessionFactoryArs"/></property>
    	</bean>
    	<!-- Objeto de negocio principal, manager principal, de Smbweb para el esquema MSMB.Implementacion con Hibernate -->
    	<bean id="smbTarget" class="com.acotelsa.smb2.smbweb.ars.hibernate.HibernateDatabaseManagerAdmin">
    		<property name="sessionFactory"><ref bean="sessionFactorySmb"/></property>
    	</bean>
    If i try to use a ref to "arsTarget", all works fine. But the problem is with "smbTarget". I've defined a bean like that on the ...-servlet.xml file:
    Code:
    <!-- Controlador de la pagina de listado de Canales-->
        <bean id="listadoCanales" class="com.acotelsa.smb2.smbweb.ars.opr.ListadoCanalesController">
        	<property name="dbManagerArs">
                <ref bean="arsTarget"/>
            </property>
            <property name="dbManagerSmb">
                <ref bean="smbTarget"/>
            </property>
        </bean>
    When i try to start Tomcat, I've this exception:
    Code:
    Error creating bean with name 'listadoCanales' defined in ServletContext resource &#91;/WEB-INF/smbars-servlet.xml&#93;&#58; Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException&#58; Invalid property 'dbManagerSmb' of bean class &#91;com.acotelsa.smb2.smbweb.ars.opr.ListadoCanalesController&#93;&#58; Bean property 'dbManagerSmb' is not writable or has an invalid setter method&#58; Does the parameter type of the setter match the return type of the getter?
    org.springframework.beans.NotWritablePropertyException&#58; Invalid property 'dbManagerSmb' of bean class &#91;com.acotelsa.smb2.smbweb.ars.opr.ListadoCanalesController&#93;&#58; Bean property 'dbManagerSmb' is not writable or has an invalid setter method&#58; Does the parameter type of the setter match the return type of the getter?
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;754&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;668&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;808&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues&#40;BeanWrapperImpl.java&#58;835&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues&#40;BeanWrapperImpl.java&#58;824&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues&#40;AbstractAutowireCapableBeanFactory.java&#58;857&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean&#40;AbstractAutowireCapableBeanFactory.java&#58;675&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;331&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;257&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;222&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;146&#41;
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;291&#41;
    	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;317&#41;
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh&#40;AbstractRefreshableWebApplicationContext.java&#58;131&#41;
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext&#40;FrameworkServlet.java&#58;303&#41;
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext&#40;FrameworkServlet.java&#58;250&#41;
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean&#40;FrameworkServlet.java&#58;219&#41;
    	at org.springframework.web.servlet.HttpServletBean.init&#40;HttpServletBean.java&#58;111&#41;
    	at javax.servlet.GenericServlet.init&#40;GenericServlet.java&#58;256&#41;
    	at com.acotelsa.smb2.smbweb.ars.SMBDispatcherServlet.init&#40;SMBDispatcherServlet.java&#58;27&#41;
    	at org.apache.catalina.core.StandardWrapper.loadServlet&#40;StandardWrapper.java&#58;924&#41;
    	at org.apache.catalina.core.StandardWrapper.load&#40;StandardWrapper.java&#58;813&#41;
    	at org.apache.catalina.core.StandardContext.loadOnStartup&#40;StandardContext.java&#58;3341&#41;
    	at org.apache.catalina.core.StandardContext.start&#40;StandardContext.java&#58;3534&#41;
    	at org.apache.catalina.core.ContainerBase.start&#40;ContainerBase.java&#58;1188&#41;
    	at org.apache.catalina.core.StandardHost.start&#40;StandardHost.java&#58;738&#41;
    	at org.apache.catalina.core.ContainerBase.start&#40;ContainerBase.java&#58;1188&#41;
    	at org.apache.catalina.core.StandardEngine.start&#40;StandardEngine.java&#58;347&#41;
    	at org.apache.catalina.core.StandardService.start&#40;StandardService.java&#58;497&#41;
    	at org.apache.catalina.core.StandardServer.start&#40;StandardServer.java&#58;2189&#41;
    	at org.apache.catalina.startup.Catalina.start&#40;Catalina.java&#58;510&#41;
    	at org.apache.catalina.startup.Catalina.execute&#40;Catalina.java&#58;400&#41;
    	at org.apache.catalina.startup.Catalina.process&#40;Catalina.java&#58;180&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
    	at java.lang.reflect.Method.invoke&#40;Method.java&#58;324&#41;
    	at org.apache.catalina.startup.Bootstrap.main&#40;Bootstrap.java&#58;203&#41;
    I can't understand, because i haven't the "setter" on my class, only the "getter" method....

  • #2
    Re: NotWritablePropertyException

    Originally posted by Jarva
    I can't understand, because i haven't the "setter" on my class, only the "getter" method....
    That might be the problem. Spring uses the setter method to set the property, so you'll need one.

    Comment


    • #3
      Ok,
      I've put getter and setter methods for the too Managers in my class, but i'm still having the problem:
      Code:
      Error creating bean with name 'listadoCanales' defined in ServletContext resource &#91;/WEB-INF/smbars-servlet.xml&#93;&#58; Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException&#58; Invalid property 'dbManagerSmb' of bean class &#91;com.acotelsa.smb2.smbweb.ars.opr.ListadoCanalesController&#93;&#58; Bean property 'dbManagerSmb' is not writable or has an invalid setter method&#58; Does the parameter type of the setter match the return type of the getter?
      org.springframework.beans.NotWritablePropertyException&#58; Invalid property 'dbManagerSmb' of bean class &#91;com.acotelsa.smb2.smbweb.ars.opr.ListadoCanalesController&#93;&#58; Bean property 'dbManagerSmb' is not writable or has an invalid setter method&#58; Does the parameter type of the setter match the return type of the getter?
      	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;754&#41;
      	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;668&#41;
      	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;808&#41;
      	at org.springframework.beans.BeanWrapperImpl.setPropertyValues&#40;BeanWrapperImpl.java&#58;835&#41;
      	at org.springframework.beans.BeanWrapperImpl.setPropertyValues&#40;BeanWrapperImpl.java&#58;824&#41;
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues&#40;AbstractAutowireCapableBeanFactory.java&#58;857&#41;
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean&#40;AbstractAutowireCapableBeanFactory.java&#58;675&#41;
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;331&#41;
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;257&#41;
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;222&#41;
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;146&#41;
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;291&#41;
      	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;317&#41;
      	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh&#40;AbstractRefreshableWebApplicationContext.java&#58;131&#41;
      	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext&#40;FrameworkServlet.java&#58;303&#41;
      	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext&#40;FrameworkServlet.java&#58;250&#41;
      	at org.springframework.web.servlet.FrameworkServlet.initServletBean&#40;FrameworkServlet.java&#58;219&#41;
      	at org.springframework.web.servlet.HttpServletBean.init&#40;HttpServletBean.java&#58;111&#41;
      	at javax.servlet.GenericServlet.init&#40;GenericServlet.java&#58;256&#41;
      	at com.acotelsa.smb2.smbweb.ars.SMBDispatcherServlet.init&#40;SMBDispatcherServlet.java&#58;27&#41;
      	at org.apache.catalina.core.StandardWrapper.loadServlet&#40;StandardWrapper.java&#58;924&#41;
      	at org.apache.catalina.core.StandardWrapper.allocate&#40;StandardWrapper.java&#58;658&#41;
      	at org.apache.catalina.core.StandardWrapperValve.invoke&#40;StandardWrapperValve.java&#58;214&#41;
      	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;643&#41;
      	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;480&#41;
      	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;995&#41;
      	at org.apache.catalina.core.StandardContextValve.invoke&#40;StandardContextValve.java&#58;191&#41;
      	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;643&#41;
      	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;480&#41;
      	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;995&#41;
      	at org.apache.catalina.core.StandardContext.invoke&#40;StandardContext.java&#58;2388&#41;
      	at org.apache.catalina.core.StandardHostValve.invoke&#40;StandardHostValve.java&#58;180&#41;
      	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;643&#41;
      	at org.apache.catalina.valves.ErrorDispatcherValve.invoke&#40;ErrorDispatcherValve.java&#58;170&#41;
      	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;641&#41;
      	at org.apache.catalina.valves.ErrorReportValve.invoke&#40;ErrorReportValve.java&#58;172&#41;
      	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;641&#41;
      	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;480&#41;
      	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;995&#41;
      	at org.apache.catalina.core.StandardEngineValve.invoke&#40;StandardEngineValve.java&#58;174&#41;
      	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;643&#41;
      	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;480&#41;
      	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;995&#41;
      	at org.apache.coyote.tomcat4.CoyoteAdapter.service&#40;CoyoteAdapter.java&#58;223&#41;
      	at org.apache.coyote.http11.Http11Processor.process&#40;Http11Processor.java&#58;405&#41;
      	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection&#40;Http11Protocol.java&#58;380&#41;
      	at org.apache.tomcat.util.net.TcpWorkerThread.runIt&#40;PoolTcpEndpoint.java&#58;508&#41;
      	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run&#40;ThreadPool.java&#58;533&#41;
      	at java.lang.Thread.run&#40;Thread.java&#58;534&#41;
      And my class is like that:


      Code:
      public class ListadoCanalesController implements Controller&#123;
          /** Logger para esta clase y sus subclasses */
          protected final Log logger = LogFactory.getLog&#40;getClass&#40;&#41;&#41;;
          
          private DatabaseManagerArs dbManagerArs;
          private DatabaseManagerAdmin dbManagerAdmin;
          
          /* &#40;No escribir Javadoc. Metodo implementado&#41;
           * @see org.springframework.web.servlet.mvc.Controller#handleRequest&#40;javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse&#41;
           */
          public ModelAndView handleRequest&#40;HttpServletRequest request, HttpServletResponse response&#41; 
          	throws ServletException, IOException 
          &#123;
              ....
           &#125;
         
          /**
           * @return Devuelve dbManagerAdmin.
           */
          public DatabaseManagerAdmin getDbManagerAdmin&#40;&#41; &#123;
              return dbManagerAdmin;
          &#125;
          /**
           * @param dbManagerAdmin El dbManagerAdmin a establecer.
           */
          public void setDbManagerAdmin&#40;DatabaseManagerAdmin dbManagerAdmin&#41; &#123;
              this.dbManagerAdmin = dbManagerAdmin;
          &#125;
          /**
           * @return Devuelve dbManagerArs.
           */
          public DatabaseManagerArs getDbManagerArs&#40;&#41; &#123;
              return dbManagerArs;
          &#125;
          /**
           * @param dbManagerArs El dbManagerArs a establecer.
           */
          public void setDbManagerArs&#40;DatabaseManagerArs dbManagerArs&#41; &#123;
              this.dbManagerArs = dbManagerArs;
          &#125;
      &#125;

      Comment


      • #4
        Ufff, i find the problem. Yeah, thanks for your answer because it's true: i need the setter method, and I've to call the property with the same name that in the "xml" file; it was obvious, but i didn't do that.:oops:

        Thanks Molotov (Good name!)

        Comment

        Working...
        X