Results 1 to 3 of 3

Thread: Bean initialization not happening

  1. #1
    Join Date
    Oct 2006
    Posts
    2

    Default Bean initialization not happening

    I'm trying to write a standalone Spring app, and I just can't get the afterPropertiesSet methods of IntitializingBean beans to get executed. This is what my main app does:

    Resource resource = new FileSystemResource("config/spring-config.xml");
    XmlBeanFactory bf = new XmlBeanFactory(resource);

    won't this by default also initialize beans that implement the required interface? Is there anything else I need to do for that to happen?

    Thanks.

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    If you would use an ApplicationContext initialization would happen automatically. For BeanFactory classes you need to invoke the "preInstantiateSingletons" method.

    Generally using an ApplicationContext is recommended for most cases.

  3. #3
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Just to confirm Andreas's advice check out the reference manual, it does cover this.
    http://www.springframework.org/docs/...nce/beans.html
    Last edited by karldmoore; Aug 27th, 2007 at 03:13 PM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

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