Results 1 to 3 of 3

Thread: Refreshing application context

  1. #1
    Join Date
    Jul 2006
    Posts
    12

    Default 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. #2

    Default

    This should not occur if you use Spring 2.0.

  3. #3
    Join Date
    Jul 2006
    Posts
    12

    Default

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

    Thx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •