10 Replies Latest reply on Aug 4, 2002 12:02 PM by noam

    MBean/EJB dependencies

    mary Newbie

      Hi,
      I need a way to ensure that an MBean starts before certain EJBs.
      I know that there is no way to make this dependency via the deployment descriptors, but is there another way?

      The problem is that the MBean and the EJBs need to be in the same JAR (they share static memory).

      Thanks!

        • 1. Re: MBean/EJB dependencies
          David Jencks Master

          Sure there is. Include a depends tag in jboss.xml, either for the ejb itself or for the container configuration. I think this is present since before 3.0

          • 2. Re: MBean/EJB dependencies
            mary Newbie

            Thanks!
            I gathered from an earlier posting this wasn't possible, but it so far appears to be working (in 3.0).

            • 3. Re: MBean/EJB dependencies
              noam Newbie

              This is very interesting because I had some problems with EJB dependency.
              Can you give an example how so set this kind of dependency?
              This element is not documented in the jboss.xml DTD

              • 4. Re: MBean/EJB dependencies
                mary Newbie

                Another question related to this...

                Now my EJBs don't start until my MBean does, very good.
                However, if I call the stop() method on my MBean, the
                EJBs are still bound and running.

                Is this expected behavior? Is there anything I can do
                to ensure the EJBs are undeployed?

                Thanks!

                • 5. Re: MBean/EJB dependencies
                  mary Newbie

                  noamhopper.. for an example:

                  After creating my MBean, I added the following to
                  jboss.xml:

                  ...

                  ...
                  user:service=MBeanName

                  ...

                  That's it!
                  BTW: "user" is the domain, it could be something else,
                  such as jboss.xxx.

                  • 6. Re: MBean/EJB dependencies
                    David Jencks Master

                    One of the odd features of the current dependency management system is that it is done through the ServiceController mbean rather than through mbean interceptors. As a result, calling a lifecycle method directly on an mbean sidesteps the dependency management.

                    To use a lifecycle method within dependency management, you need to call the e.g. service controller stop(ObjectName) method.

                    Note that this will not undeploy the ejb, merely stop it. I think that this will prevent invocations from getting to it, I think it will not unbind it from jndi.

                    • 7. Re: MBean/EJB dependencies
                      mary Newbie

                      Thanks,
                      This stops my EJBs preventing them from being called.

                      There is still a problem however. Now if I start the MBean again (via the ServiceController) the dependent EJBs can't be started again. The error I am getting (after the MBean appears to be started successfully is):

                      MBeanException: Exception in MBean operation 'start(,javax.management.ObjectName)'
                      Cause: org.jboss.deployment.DeploymentException: Could not set up environment; - nested throwable: (javax.naming.NameAlreadyBoundException; remaining name 'env')


                      So, I thought then that as a last resort I could just stop/start the EJB explicitly, however I'm not sure how to do that via the management interface. My understanding is the that the Domain="jboss.j2ee", key="service", name="EjbModule,url=file%<path_of_jar>". Is this wrong?
                      The exception I get is this:

                      javax.management.MalformedObjectNameException: malformed key/value pair: service=EjbModule,url=file%/usr/local/jboss/server/default/deploy/ejb_deploy.jar
                      at javax.management.ObjectName.initProperties(ObjectName.java:302)
                      at javax.management.ObjectName.(ObjectName.java:77)
                      at client.cli.isman_cli.main(isman_cli.java:161)
                      javax.management.MalformedObjectNameException: malformed key/value pair: service=EjbModule,url=file%/usr/local/jboss/server/default/deploy/ejb_deploy.jar


                      Any help is appreciated!

                      Thanks

                      • 8. Re: MBean/EJB dependencies
                        mary Newbie

                        Thanks, that stops my EJBs.

                        However, that's not all. Now if I start my MBean again (via the ServiceController) my dependent EJBs can't restart. The error is (after my MBean appears to get started successfully):

                        10:02:00,791 INFO [MyMBean] Started
                        10:02:00,797 ERROR [MessageDrivenContainer] Could not set up environment
                        javax.naming.NameAlreadyBoundException; remaining name 'env'
                        at org.jnp.server.NamingServer.createSubcontext(NamingServer.java:451)
                        at org.jnp.interfaces.NamingContext.createSubcontext(NamingContext.java:763)
                        at org.jnp.interfaces.NamingContext.createSubcontext(NamingContext.java:749)
                        ...


                        I thought then that maybe as a last resort I could explicitly start/stop my EJBs via the ServiceController too... However, I keep getting a MalformedObjectNameException on the key/value pair. Isn't the domain="jboss.j2ee", key="service",name="EjbModule,url=file%<path_of_jar" ???


                        javax.management.MalformedObjectNameException: malformed key/value pair: service=EjbModule,url=file%/usr/local/jboss/server/default/deploy/ejb_deploy.jar
                        at javax.management.ObjectName.initProperties(ObjectName.java:302)
                        at javax.management.ObjectName.(ObjectName.java:77)


                        Any help is appreciated!
                        Thanks

                        • 9. Re: MBean/EJB dependencies
                          mary Newbie

                          Thanks, that stops my EJBs.

                          However, that's not all. Now if I start my MBean again (via the ServiceController) my dependent EJBs can't restart. The error is (after my MBean appears to get started successfully):

                          10:02:00,791 INFO [MyMBean] Started
                          10:02:00,797 ERROR [MessageDrivenContainer] Could not set up environment
                          javax.naming.NameAlreadyBoundException; remaining name 'env'
                          at org.jnp.server.NamingServer.createSubcontext(NamingServer.java:451)
                          at org.jnp.interfaces.NamingContext.createSubcontext(NamingContext.java:763)
                          at org.jnp.interfaces.NamingContext.createSubcontext(NamingContext.java:749)
                          ...


                          I thought then that maybe as a last resort I could explicitly start/stop my EJBs via the ServiceController too... However, I keep getting a MalformedObjectNameException on the key/value pair. Isn't the domain="jboss.j2ee", key="service",name="EjbModule,url=file%<path_of_jar" ???


                          javax.management.MalformedObjectNameException: malformed key/value pair: service=EjbModule,url=file%/usr/local/jboss/server/default/deploy/ejb_deploy.jar
                          at javax.management.ObjectName.initProperties(ObjectName.java:302)
                          at javax.management.ObjectName.(ObjectName.java:77)


                          Any help is appreciated!
                          Thanks

                          • 10. Re: MBean/EJB dependencies
                            noam Newbie

                            I tried to play with EJB dependency and it seems to me that it works only in 3.0.1.
                            When I try this in 3.0.0 the deployment of the EJB seems successful and no errors are reported but the JNDI name of the EJB is not bound.