Announcement Announcement Module
Collapse
No announcement yet.
Refreshing application context Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Refreshing application context

    In my application I'd like to be able to refresh the config for aop at runtime (add/remove traces, ...).
    I use ClassPathXmlApplicationContext. My first try has been to update the XML file and then to invoke the refresh method of the context. It works sometimes but getBean and refresh methods for example is not synchronized. Consequently as my application is still running when I invoked refresh, from time to time I have the following exception:
    Code:
    Exception in thread "main" java.lang.IllegalStateException: BeanFactory not initialized - call 'refresh' before accessing beans via the context: org.springframework.context.support.ClassPathXmlApplicationContext: display name [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=14737862]; startup date [Wed Jul 19 15:58:02 CEST 2006]; root of context hierarchy
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:103)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:606)
    	at fr.biomerieux.locator.runtime.Main.main(Main.java:69)
    getBean is invoked before refresh method terminate. Solution might be to synchronize all invocation of getBean and refresh but it looks like something little extrem ...

    Is there a better solution to be able to refresh application context at runtime ?

  • #2
    This should not occur if you use Spring 2.0.

    Comment


    • #3
      You're right. I was using spring 2.0-m4. I have migrate to 2.0-rc2. It works fine !

      Thx

      Comment

      Working...
      X