6 Replies Latest reply on Jun 9, 2011 3:12 AM by jaikiran

    MBean Depends on Server Start

    ab_99

      Is it possible for a MBean to depend on server start instead of a particular jar or service?

       

      --Anurag

        • 1. Re: MBean Depends on Server Start
          alesj

          How exactly do you mean this?

          If the server is not started, the mbean doesn't run anyway.

          • 2. Re: MBean Depends on Server Start
            ab_99

            Can I delay the MBean start method till the server startup has been completed?

             

            --Anurag

            • 3. Re: MBean Depends on Server Start
              alesj

              The Bootstrap sub-project / layer pushes notification when the server is startting / fully started.

              See if you can somehow use this for your task.

              * http://anonsvn.jboss.org/repos/jbossas/projects/bootstrap/trunk/

               

              e.g.

              Create a new service / MBean / POJO, which is able to install new MBeans + listens for these notifications.

              When it receives "Server.STARTED" event, simply install your MBean.

              And uninstall this MBean when initial service goes down.

              • 4. Re: MBean Depends on Server Start
                jaikiran

                Anurag Bhatia wrote:

                 

                Can I delay the MBean start method till the server startup has been completed?

                 

                --Anurag

                What's the reason you want to do that?

                • 5. Re: MBean Depends on Server Start
                  ab_99

                  The mbean in the sar calls an ejb method in the one of the othe jar files.

                  I havethe depends tag setup in the jboss-service.xml as -

                   

                  <depends>jboss.j2ee:jndiName=com/utils/configuration/ConfigurationLocal,service=EJB</depends>

                   

                  When I start the server MBean tries to do a lookup to the session bean, however the lookup fails with the exception -

                  10:53:25,955 WARN  [ServiceController] Problem starting service

                  10:53:23,424 ERROR [Adapter] envLookUp

                  javax.naming.NameNotFoundException: env not bound

                          at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)

                          at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)

                          at org.jnp.server.NamingServer.getObject(NamingServer.java:543)

                          at org.jnp.server.NamingServer.lookup(NamingServer.java:267)

                          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)

                          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:774)

                          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)

                          at javax.naming.InitialContext.lookup(InitialContext.java:392)

                   

                  When I re-invoke the start() method via the JMX console after the server startup has been completed, the lookup succeeds.

                  • 6. Re: MBean Depends on Server Start
                    jaikiran

                    The value you have specified in the <depends> is wrong. Let's continue this discussion in your other thread here http://community.jboss.org/thread/167673?tstart=0