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:
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 ...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)
Is there a better solution to be able to refresh application context at runtime ?


Reply With Quote