2 Replies Latest reply on May 1, 2007 12:25 PM by dimitris

    how to get mbean to deploy after ejb is bound

    lost_traveller

      I have an MBean contained within a SAR file contained within an EAR. In the MBean I do a JNDI lookup for a SessionBean but it is failing because the MBean is deployed before the EJB. How do I get the MBean to deploy after the EJBs have been bound to the JNDI?
      Adding a depends on the EJB deployer makes no difference to when the MBean is deployed:

      <mbean code="foo.bar.FooBarService"
       name="Foo:service=foo.bar.FooBarService">
       <depends>jboss.ejb:service=EJBDeployer</depends>
       </mbean>


        • 1. Re: how to get mbean to deploy after ejb is bound
          mazz

          I've had to do this very thing in my app. The easist thing to do is:

          1) In your MBean, do not do anything that requires the EJBs in your start() method (that is, do not expect the EJBs to be deployed when your MBean is deployed).
          2) Create a "reallyStartNow" method in your MBean - this is when it can perform its startup routines that require the EJBs to be deployed
          3) if you don't already have a war in your ear, create one
          4) create a StartupServlet and make sure it is loaded at startup (defined in web.xml appropriately)
          5) in your StartupServlet's init() method, use JMX to find your MBean and invoke the "reallyStartNow" method.

          MBeans are deployed first, then EJBs within your EAR, then Webapps within your EAR are started last. So, your init() method is called at a point in time when you know everything else is ready.

          This works perfectly for me.

          • 2. Re: how to get mbean to deploy after ejb is bound
            dimitris