Announcement Announcement Module
No announcement yet.
Session bean destroy order Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Session bean destroy order

    Hello Spring community,

    I am developing a web application with Spring 3.2.1 and JSF2. Now I have a question on session beans and the @PreDestroy callback...

    Assuming I have two session beans where one session bean gets the other session bean injected.
    Is there a defined order in that way that the session bean which is referenced by an other session bean gets
    destroyed after the other one - in the following scenario: Is the AuthManager instance always destroyed
    after the ExecutorBean instance when the session is invalidated so that I can access fields from the referenced bean within the pre-destroy method?

    public class AuthManager {
      private int userId;
      public int getUserId() {
        return userId;
      public void login() {
        userId = 10;
      public void logout() {
        // Invalidate session
    public class ExecutorBean {
      // Reference to the other session bean
      private AuthManager authManager;
      public void preDestroy() {
        // Is it guaranteed that the authManager bean is always destroyed after the executor bean?
    Thanks in advance, best regards,