JBoss Community

Re: EJB lookup during server shutdown

created by Maycon Oliveira in JBoss AS 7 Development - View the full discussion

The problem still happen.  Can you confirm ? Maybe I coded something wrong?

 

Just hit ctrl + c when the "STOP SERVER NOW!!!!" message shows and the exception will happen.

 

Here is my test: (I cleaned up the @DependsOn beacause I tried a lot of combinations and the problem persist, where I put this annotation?)

 

 

 

 

@Singleton
@Startup
public class InitializerBean {
 
 
          @EJB
          private FirstSessionBean firstSessionBean;
 
 
          @PostConstruct
          public void init() {
                    try {
                              firstSessionBean.someOperation();
                    } catch (Exception e) {
                              e.printStackTrace();
                    }
          }
}

 

 

@Stateless
@LocalBean
public class FirstSessionBean {
 
 
          @EJB
          private SecondSessionBean secondSession;
 
 
          public void someOperation() {
                    try {
                              // while (true) {
                              System.out.println("STOP SERVER NOW!!!!");
                              Thread.sleep(5000);
                              secondSession.someOperation();
                              System.out.println("INVOCATION COMPLETED");
                              // }
                    } catch (Exception e) {
                              System.out.println("INVOCATION FAILED! ");
                              e.printStackTrace();
                    }
          }
 
 
          @PreDestroy
          public void destroy() {
                    System.out.println("FirstSessionBean.destroy");
          }
 
 
}

 

 

@Stateless
@LocalBean
public class SecondSessionBean {
 
 
          public void someOperation() {
                    System.out.println("Some operation");
          }
 
 
          @PreDestroy
          public void destroy() {
                    System.out.println("SecondSessionBean.destroy");
          }
}

 

 

If you guys prefer, I have uploaded the eclipse project and the ejb.jar file:

 

http://www.4shared.com/file/-1q3LQtw/file.html

 

http://www.4shared.com/zip/cG3YjHs_/file.html

Reply to this message by going to Community

Start a new discussion in JBoss AS 7 Development at Community