1 Reply Latest reply on Sep 17, 2013 10:02 AM by skay088

    @Dispose method not called for CDI beans used by remote EJB?

    pedrokowalski

      Howdy Guys,

       

      I have a CDI bean which has a @Produces method with @RequestScoped. This bean is then injected into SLSB.

      The @Dispose method of the CDI bean should be called when the bean is out of scope. The RequestScoped should work for Servlets, WebServices as well as for remote EJBs.

       

      Surprisingly, the @Dispose method for CDI bean injected into remote EJB is NOT called.

       

      I've created a simple application using Arquillian that runs on JBoss AS 7.1 and shows how I thought it should work. It's on my github: https://github.com/PiotrNowicki/jboss7-cdi-dispose

       

      For RESTful WS it works correct - for remote EJB it doesn't.

       

      Thanks in advance for any help.

        • 1. Re: @Dispose method not called for CDI beans used by remote EJB?
          skay088

          Hi,

           

          A remote EJB is supposed to run into a separate JVM : it is not supposed to be mixed with request-scoped CDI beans.

           

          I'm not shure about what you're trying to do, but I think you should consider the dedicated EJB annotation for the EJB lifecycle :

          @PreDestroy

           

          And handle the remote EJB lifecycle completely separated from your CDI bean.

           

          BR