2 Replies Latest reply on Mar 23, 2012 5:00 AM by Jozef Hartinger

    Stateless session bean is not destroyed

    H Dam Newbie

      Hi,

      I have following code

       

      @Stateful
      @SessionScoped
      public class LoginUserManager {
                private LoginUser loginUser;
      
                /**
                 * @return the loginUser
                 */
                @Produces
                @Named
                @LoggedInUser
                public LoginUser getLoginUser() {
                     return loginUser;
                }
           ...............................
      }
      
      
      @Stateless
      public class BranchService {
           @Inject
           @LoggedInUser
           private LoginUser loginUser;
      
           @Inject
           protected EntityManager em;
      
           public void test() {
                ...................
           }
      .....................
      }
      
      public class TestList {
           @Inject
           private BranchService branchService;
      
           @PostContruct
           public void init() {
                branchService.test();
                .............
           }
      }
      
      

      At first, I logged in with user a1, loginUser injected in BranchService is a1. After that, I logged out, and logged in with user a2, at this time, I consider that loginUser injected in BranchService is a1 (loginUser saved in session is right). After debugging, I consider that although I logged out, but when logged in again, and call method test() of BranchService, the instance of BranchService is the same, I think it not be destroyed after invoking test(). What am I wrong? Please help me. Thanks.