2 Replies Latest reply on Aug 3, 2004 1:03 AM by genman

    mbean / sar depend on a war?

    pharaohh

      Is there a way for an MBean (SAR) to depend on a web application WAR being deployed/started first?

      I have a notification service (MBean) I would like to start only after everything else has deployed and started (which includes the web application being up and running).

      I know a standard way is to start the service by looking up the MBean from JNDI from a ServletContextListener in the web tier (implying the web tier is the last component to be deployed). Therefore, when the context listener is executed after startup, you can assume everything else in the whole application has been deployed.

      Although this is OK, it would be a lot easier and quicker if I can just specify the following mbean definition:

      <mbean code="com.some.JmxMBeanImpl"
       name="MyDomain:service=MyJmxImpl">
       <depends>jboss:service=Naming</depends>
       <depends>jboss.jca:name=hibernateService,service=hibernateService</depends>
       <depends>jboss.management.local:J2EEApplication=myapp.ear,J2EEServer=Local,j2eeType=WebModule,name=myapp.war</depends>
      </mbean>


      (where myapp.war is inside myapp.ear).

      Having a legitimate depends tag is nicer than the servlet approach in some cases because sometimes we may not even want to start the service upon deployment. In this case, we'd have to change code to prevent the service from being started. The depends approach would allow us to just change a config file only.

      I thought the above code would work, but it doesn't. Am I specifying the war depends tag wrong?

      Any help at all is greatly appreciated.

      Regards,

      Phar

        • 1. Re: mbean / sar depend on a war?
          lepe

          had the same 'problem' but found out that you can have an MBean do depend only on other MBeans - not on a war.

          One solution might be to pack it as a russian doll - pack the war inside your sar. Then the war will be deployd before your sar. But on other hand - you also says that you sometimes don't want to deploy the sar at all... Your way to go might be to change the deployment sorter to match your needs instead.

          /L

          • 2. Re: mbean / sar depend on a war?
            genman


            When you deploy a .war file, I believe several MBeans are created. You can check via the JMX console which ones these are. I think at least each Servlet creates an MBean.