10 Replies Latest reply on Mar 27, 2002 11:21 AM by zommick

    Custom MBean deploy order in JBoss3.0b2 ?

    zommick

      I have created a custom mbean service that I wish to deploy after the other services in the deploy directory. How do I control the order in which services are started inside the deploy directory? I've tried to use the 'depends' attribute; however, I get exceptions. If that is the correct methodology, can someone provide the correct syntax to deploy an mbean after everything else has been deployed?

      Thanks,
      Jordan

        • 1. Re: Custom MBean deploy order in JBoss3.0b2 ?
          davidjencks

          You can't really guarantee that an mbean will be deployed after _everything_ else, only the things you depend on. Also, your mbean needs to use the jboss lifecycle approach. The instance will be created and configured as soon as the deployer finds it, however create and start will only be called when the mbeans it depends on are created and started. So, figure out exactly what is necessary for yours to start. Note that with cvs head you can depend on ejbs by depending on their Container mbeans and I think ejb modules similarly.

          If you do not need references to the mbeans you depend on, the syntax is

          [object name]
          If you do need the reference, put an ObjectName valued property in your mbean and use
          <depends optional-attribute-name="propname">[ObjectName]

          • 2. Re: Custom MBean deploy order in JBoss3.0b2 ?
            marc.fleury

            David this is a perfect example of when you would want to put it in a single file and the order the file dictates the order in which it is deployed (without all the depends construct). So a simple answer to this is to build one big service.xml file with all the beans that depend on each other and deploy THAT in the /deploy directory.

            marcf

            • 3. Re: Custom MBean deploy order in JBoss3.0b2 ?
              zommick

              How do I put a 'depends' on the classes within the jar files that I specify in my classpath statement at the top of my service? I have MBeans that appear in the jar file along with other ejbs. ALL the objects in my jar file (not just MBeans) cannot be deployed until the dependencies have cleared.

              • 4. Re: Custom MBean deploy order in JBoss3.0b2 ?
                davidjencks

                If you either put all the classes (but not the dds) in lib or pack everything into a sar or ear, then all classes will be loaded before any dd is looked at. You can then get explicitly configured mbeans to wait for ejb's or ejb modules, since these are now mbeans participating in jboss service lifecycle. If you want to deploy ejbs after mbeans you have to do something like pack the sar inside an ejb-jar (probably putting them at the same level in an ear would also work). There is currently no way to have an explicit dependency of an ejb on an mbean.

                • 5. Re: Custom MBean deploy order in JBoss3.0b2 ?
                  zommick

                  I’m not sure I'm making myself clear. I want to deploy my jar files that have EJBs; however, they require a database connection, jndi, etc. So, I need my EJBs to be deployed AFTER the database connection, jndi, jms, etc.. have been deployed. And, my mbeans (which are in a different jar file) are dependent on those EJBs to do stuff. How do I do that?



                  Thanks very much!

                  Jordan

                  • 6. Re: Custom MBean deploy order in JBoss3.0b2 ?
                    davidjencks

                    OK, its much easier to think about if I know exactly what you are trying to do;-)

                    Lets say you have 3 things: db pool mbean, ejb jar, and other mbeans, and you want them deployed in this order.
                    Solution 1:
                    Make a db.sar with only the jboss-service.xml for the db pool (you can put the driver jar in there too if you want).

                    Make another sar with:

                    db.sar
                    ejb.jar
                    other mbean classes
                    META-INF/jboss-service.xml with the other mbean configs.

                    Why it works:
                    Inner packages (db.sar and ejb.jar) are deployed before outer packages, and among packages on the same level (db.sar and ejb.jar) sars are deployed before jars.

                    Solution 2:

                    make a package (could be just a jar, that is simplest) with

                    all-mbeans.sar
                    ejb.jar

                    In the mbean config for the mbeans that need the ejb's started before they start, put elements with the ObjectNames of the containers for the ejbs they need to wait for (NOT the jsr-77 ObjectNames, which I think do not participate in the service lifecycle management).

                    Why it works: There are only 2 packages, peers: therefore the sar will be deployed before the jar. The mbeans that have for the ejb's will wait to start until the ejbs are started.

                    If you are starting up the server with the packages in place, just putting the 2 packages in deploy should work fine. Otherwise it will probably work fine if you copy the sar into deploy, then the ejb.jar. You want to avoid the possibility of the scanner finding the ejb jar but not the sar on one pass.

                    For your mbeans, remember first all classes in a package are loaded, then everything is instantiated and "create"-ed, then everything is "start"ed. So make sure the code that depends on something else being there is executed in a start or startService (if you descend from ServiceMBeanSupport) method.

                    • 7. Re: Custom MBean deploy order in JBoss3.0b2 ?
                      zommick

                      In the latest JBoss 3.0b from HEAD can you deploy these files using the expanded directory structure from the sar file?? I tried to create a directory called test.sar and placed the expanded files underneath, but JBoss just hangs and doesn't do anything.

                      • 8. Re: Custom MBean deploy order in JBoss3.0b2 ?
                        davidjencks

                        Actually I haven't tried it. If you use archives rather than unpacked directories does it work? How are you dealing with the inner packages? If you can supply an example I would be more likely to look at this soon.

                        • 9. Re: Custom MBean deploy order in JBoss3.0b2 ?
                          zommick

                          Yes, as a complete sar file it will deploy as you outlined in the previous message; however, I wanted to unpack it so that I could create symbolic links to the jar files and when one gets updated, the clients don't need all files, but only the ones that have changed.

                          • 10. Re: Custom MBean deploy order in JBoss3.0b2 ?
                            zommick

                            I've created a sar file as you've suggested. The database connection pooling is created first which the other internal jars needed; however, when it tries to deploy the rest of the internal jar classes, I get another exception because its deploying them too soon. I've tried to put some depends in my database connection service because its deploying first; however, that doesn't seem to do anything for the rest of the internal jars.

                            2002-03-27 08:13:28,668 DEBUG [org.jboss.ejb.plugins.jms.JMSContainerInvoker] initializing
                            2002-03-27 08:13:28,683 ERROR [org.jboss.ejb.MessageDrivenContainer] Serious error in init:
                            javax.naming.NameNotFoundException: ConnectionFactory not bound
                            at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
                            at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
                            at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
                            at org.jnp.server.NamingServer.lookup(NamingServer.java, Compiled Code)
                            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java, Compiled Code)
                            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
                            at javax.naming.InitialContext.lookup(InitialContext.java:350)
                            at org.jboss.ejb.plugins.jms.DLQHandler.create(DLQHandler.java:128)
                            at org.jboss.ejb.plugins.jms.JMSContainerInvoker.innerCreate(JMSContainerInvoker.java, Compiled Code)
                            at org.jboss.ejb.plugins.jms.JMSContainerInvoker.create(JMSContainerInvoker.java:415)
                            at org.jboss.ejb.MessageDrivenContainer.create(MessageDrivenContainer.java:168)
                            at org.jboss.ejb.Container.invoke(Container.java, Compiled Code)
                            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java, Compiled Code)
                            at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:673)
                            at $Proxy1.create(Unknown Source)
                            at org.jboss.system.ServiceController.create(ServiceController.java, Compiled Code)
                            at java.lang.reflect.Method.invoke(Native Method)
                            at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java, Compiled Code)
                            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java, Compiled Code)
                            at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java, Compiled Code)
                            at $Proxy4.create(Unknown Source)