2 Replies Latest reply: Aug 21, 2011 5:01 AM by 839471 RSS

    Reload property file without restarting tomcat.

    839471
      Hi,

      I am new to Spring 3.0 . How can i reload my property file without restarting tomcat ?.

      i used this peace of code in applicationcontext.xml and also used the jar file provided here :
      http://www.wuenschenswert.net/wunschdenken/archives/127

      and i am getting error regarding bean creation.......

      <bean id="configproperties"
      class="net.wuenschenswert.spring.ReloadablePropertiesFactoryBean">
      <property name="location" value="file:src/test/net/wuenschenswert/spring/example/config.properties"/>
      </bean>

      <bean id="propertyConfigurer"
      class="net.wuenschenswert.spring.ReloadingPropertyPlaceholderConfigurer">
      <property name="properties" ref="configproperties"/>
      </bean>

      <bean id="mybean" class="net.wuenschenswert.spring.example.MyBean">
      <property name="cachesize" value="#{my.cache.size=100}"/>
      </bean>

      <!-- regularly reload property files. -->
      <bean id="timer" class="org.springframework.scheduling.timer.TimerFactoryBean">
      <property name="scheduledTimerTasks">
      <bean id="reloadProperties" class="org.springframework.scheduling.timer.ScheduledTimerTask">
           <property name="period" value="1000"/>
           <property name="runnable">
           <bean class="net.wuenschenswert.spring.ReloadConfiguration">
           <property name="reconfigurableBeans">
           <list>
                <ref bean="configproperties"/>
      <!-- others... -->
           </list>
           </property>
           </bean>
           </property>
      </bean>
      </property>
      </bean>

      needed help very urgentely........
        • 1. Re: Reload property file without restarting tomcat.
          EJP
          What* error?

          It never ceases to amaze me that people can post statements like 'I get an error' and apparently seriously expect to get help. Urgently, in this case.
          • 2. Re: Reload property file without restarting tomcat.
            839471
            Context initialization failed
            org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'propertyConfigurer' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'configproperties' while setting bean property 'properties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configproperties' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [src/conf/leadreportview.properties]
                 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
                 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
                 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1317)
                 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:194)
                 at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:603)
                 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:405)
                 at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
                 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
                 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
                 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
                 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
                 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
                 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
                 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
                 at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
                 at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
                 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
                 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
                 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
                 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
                 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
                 at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
                 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
                 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
                 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
                 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
                 at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
                 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:288)
                 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)