4 Replies Latest reply on Feb 14, 2007 4:52 AM by dimitris

    How do force the module org.jboss.ejb.EjbModule to be depend

    krimsonnitehawk

      Hi,

      I would like for my ejb module to be dependent on a service (SAR file). If the service code fails I don't want JBoss 4.0.5 to deploy my ejb module. Where inside jBoss does the mbean for this module get created? In the root of the jboss deploy folder in my apps service file I have the code:

      <mbean code="org.jboss.ejb.EjbModule" name="jboss.j2ee:service=EjbModule,module=ejb-files.jar">
       <depends>myclass.package:service=serviceName</depends>
       </mbean>


      If I run this I get the error:

      Incomplete Deployment listing:

      --- Incompletely deployed packages ---
      org.jboss.deployment.DeploymentInfo@8a11c4ff { url=file:/usr/share/jboss4/server/default/deploy/myapps-service.xml }
      deployer: org.jboss.deployment.SARDeployer@6caf16
      status: Deployment FAILED reason: org.jboss.ejb.EjbModule.(); - nested throwable: (java.lang.NoSuchMethodException: org.jboss.ejb.EjbModule.())
      state: FAILED
      watch: file:/usr/share/jboss4/server/default/deploy/myapps-service.xml
      altDD: null
      lastDeployed: 1171288650635
      lastModified: 1171288650000
      mbeans:


      I think it is because I am not supplying the correct mbean attributes for the ejbmodule. For the container to initialise it needs certain attributes - what are they? Also if I am forcing the creation of the MBean for the ejbmodule will this ot clash with JBoss attempting to start it automatically?

      Any help would be much appreciated!

      Thanks

      Andy

        • 1. Re: How do force the module org.jboss.ejb.EjbModule to be de
          dimitris

          You just need to put a dependency in the META-INF/jboss.xml descriptor on the target mbean (see the jboss-4_0.dtd)

          • 2. Re: How do force the module org.jboss.ejb.EjbModule to be de
            krimsonnitehawk

            Hi, thanks for getting back. I've tried putting the following code inside the META-INF/jboss.xml file

            <container-configurations>
            
             <container-configuration>
             <container-name>Schema Update Dependent</container-name>
             <depends>package.myclass:service=servicename</depends>
             </container-configuration>
            
             </container-configurations>
            


            Is this the correct place for the depends tag, or should it be within one of the tags as defined in the dtd? In jboss_4_0.dtd it says "The standard configurations will automatically be used if no custom configuration is specified." Do I need to more elements within my custom container-configuration tag so that jboss will pick it up instead of using one of the defaults defined in jboss4/server/default/conf/standardjboss.xml. How do find out which container configuration jboss is using to deploy my ejb module? I think the above code is currently being ignored.

            When I deploy my ear the ejb module still seems to deploy even although I have called stop on the service. I am wondering if the stop isn't actually stopping my service. I have the following code in my service class.

            First the interface.

            package package.myclass;
            
            public interface ServiceMBean {
            
            public void start() throws Exception;
            
            public void stop() throws Exception;
            
            public void create() throws Exception;
            
            public void destroy() throws Exception;
            
            }


            The service class -

            package package.myclass;
            
            public class Service implements ServiceMBean{
            
            public void start() throws Exception {
            
            //the important bit
            
            ObjectName ServiceSARClass = new ObjectName("package.myclass:service=servicename");
            // to get a handle on the MBeanServer
            MBeanServer server = MBeanServerLocator.locateJBoss();
            // if an exception occurs within the code
            server.invoke(ServiceSARClass,"stop",null,null);
            }
            
            public void destroy() throws Exception {
             logger.debug("Destroying jboss:service=servicename");
             }
            
             public void stop() throws Exception {
             logger.debug("Stopping jboss:service=servicename");
            
             }
            public void create() throws Exception {
             }
            


            Calling server.invoke(ServiceSARClass,"stop",null,null); seems to call the stop method of this class but my debug shows that the start method contiunes to run. All my stop method contains is some debug - do I need more code to get actually get the service to stop? I am aware that stop simply un-registers the MBean from the MBeanServer. Is this enough so that when the ejb module deploys it see that its dependency has failed and in turn stops its deployment?

            Again thanks in advance for any help!

            Andy



            • 3. Re: How do force the module org.jboss.ejb.EjbModule to be de
              krimsonnitehawk

              hi,

              Is this the correct place for the depends tag, or should it be within one of the tags as defined in the dtd?

              should read..

              Is this the correct place for the depends tag, or should it be within one of the

              <entity/>
              tags as defined in the dtd?

              • 4. Re: How do force the module org.jboss.ejb.EjbModule to be de
                dimitris

                If your mbean service fails with an exception in the start method, then jboss will assume it has FAILED and so all dependend mbeans (including the EJB container) will never start.

                Normally we don't manually call stop() after a failled start().