Announcement Announcement Module
Collapse
No announcement yet.
Lazy-init & destroy-method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lazy-init & destroy-method

    Hello,
    Could anyone tell me something about the execution of the "destroy-method" for a "lazy-init" singleton bean that is instantiated by a "getBean"?
    Thanks in advance.
    Regards.

  • #2
    And what would you like to know? There is no difference in the execution of the destroy-method betwee an lazy and non lazy bean. The destroy-method is called when the Spring container shutdowns. Read the reference guide, this explains a lot about the lifecycle.

    Comment


    • #3
      Consider the next:
      An "eager instantiated" singleton bean "A", instantiates "lazy init" singleton bean "B" via "getBean" in its initialization method.
      At context shutdown, it seems that "destroy method" is invoked for bean "A" but not for bean "B".
      May I made a mistake or is there any explanation for this?
      Regards.

      Comment


      • #4
        How are you retrieving the bean with getBean? How do you get access to the applicationcontext? There must be some mistake in your code, either your bean isn't a singleton, or it isn't managed by spring, there is an error in the destroy method.... Post some code/configuration when doing so please use the [ code][/code ] tags.

        Comment


        • #5
          There was also a bug in 2.1-m3 (maybe earlier 2.1 versions) that prevented the destroy-method from being called in some circumstances (SPR-3800). Which version of Spring are you using?

          Comment

          Working...
          X