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

  • help: Bean property 'lazyInit' is not writable or has an invalid setter method

    Error creating bean with name 'dataSource': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'lazyInit' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'lazyInit' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

    Though the message is self explanatory, i could not find where i am going wrong. Please help me through this

    Thanks in advance.

  • #2
    I am having the same issue. I configured a JNDI datasource that has worked for months. I start work with it today, and it breaks. Code follows...

    Edit:
    Tomcat - 6.0.32
    Spring - 3.0.3

    ApplicationContext.xml
    Code:
      <jee:jndi-lookup id="dataSource"
                       jndi-name="jdbc/RouteNGN" />
    Web.xml
    Code:
      <resource-ref>
        <res-ref-name>jdbc/RouteNGN</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>
    Tomcat Context.xml
    Code:
    	<Resource name="jdbc/RouteNGN"
    	          auth="Container"
    			  type="javax.sql.DataSource"
    			  maxActive="100"
    			  maxIdle="30"
    			  maxWait="10000"
    			  username="username"
    			  password="password"
    			  driverClassName="com.mysql.jdbc.Driver"
    			  url="jdbc:mysql://localhost:3306/RouteNGN" />
    Throws
    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'lazyInit' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'lazyInit' 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:1291)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
    	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4420)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4733)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
    	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
    	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
    	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
    	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
    	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    	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:597)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'lazyInit' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'lazyInit' 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:1016)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:899)
    	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
    	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1287)
    	... 42 more
    Last edited by mkeith6911; Jun 8th, 2011, 03:40 PM.

    Comment


    • #3
      I am having the same issue since this morning. The error I get is:

      Code:
      Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'lazyInit' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'lazyInit' 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:1024)
      	at org.springframework.beans.ns.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1024)
      	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:900)
      	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
      	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358)
      	... 43 more
      Jun 8, 2011 2:16:36 PM org.apache.catalina.core.StandardContext startInternal
      SEVERE: Error listenerStart
      Jun 8, 2011 2:16:36 PM org.apache.catalina.core.StandardContext startInternal
      SEVERE: Context [/galileo] startup failed due to previous errors
      BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:900)
      	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
      	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358)
      	... 43 more
      My datasource mapping file is:

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:jee="http://www.springframework.org/schema/jee"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd">
      
        <description>Spring/Hibernate Configuration</description>
      
        <jee:jndi-lookup id="dataSource"
          jndi-name="java:comp/env/jdbc/MyDataSource" />
      
        <bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager">
          <property name="sessionFactory" ref="sessionFactory" />
        </bean>
      
        <bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
          <property name="dataSource" ref="dataSource" />
          <property name="mappingLocations">
            <list>
              <value>classpath:/hibernate/UserTypes.hbm.xml</value>
            </list>
          </property>
          <property name="mappingDirectoryLocations">
            <list>
              <value>classpath:/hibernate</value>
            </list>
          </property>
          <property name="hibernateProperties">
            <props>
              <prop key="hibernate.dialect">
                org.hibernate.dialect.PostgreSQLDialect
              </prop>
              <prop key="hibernate.show_sql">false</prop>
              <prop key="hibernate.max_fetch_depth">4</prop>
              <prop key="hibernate.default_batch_fetch_size">50</prop>
              <prop key="hibernate.cache.provider_class">
                net.sf.ehcache.hibernate.SingletonEhCacheProvider
              </prop>
              <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
              <prop key="hibernate.cache.use_query_cache">true</prop>
              <prop key="hibernate.cache.use_second_level_cache">true</prop>
              <prop key="hibernate.cache.use_structured_entries">true</prop>
              <prop key="hibernate.generate_statistics">true</prop>
              <prop key="hibernate.jdbc.batch_size">50</prop>
              <prop key="net.sf.ehcache.configurationResourceName">ehcache.xml</prop>
            </props>
          </property>
        </bean>
      </beans>

      Comment


      • #4
        I believe the xsd may have been altered since yesterday.

        The 3.1 version has the lazyinit property with a default of true. I am uncertain if it was there yesterday.

        The 3.0 version has no mention (that I can find) of the lazyinit property, but at runtime still throws the same exception.

        The 2.5 version has no mention (that I can find) of the lazyinit property, and will NOT throw the exception at runtime.

        Until this is fixed, I will be using the 2.5 version. You should give that a try and see if your application starts up again.

        Comment


        • #5
          Thanks it worked for me too. I used 3.0 earlier I had 3.1

          Comment

          Working...
          X