7 Replies Latest reply on Jun 1, 2002 12:00 AM by David Brown

    simple start up service based on mbeans

    David Brown Newbie

      Adrian,
      thanks for the advice, the server now seems to pick up the classes okay. There is still something wrong, though. I now get the following complaint:

      javax.management.NotCompliantMBeanException: example.StartUp does not implement the example.StartUpMBean interface or the DynamicMBean interface
      at com.sun.management.jmx.Introspector.testCompliance(Introspector.java:130)
      at com.sun.management.jmx.MetaData.testCompliance(MetaData.java:132)
      at com.sun.management.jmx.MBeanServerImpl.createMBean(MBeanServerImpl.java:759)
      at javax.management.loading.MLet.getMBeansFromURL(MLet.java:540)
      at javax.management.loading.MLet.getMBeansFromURL(MLet.java:369)
      at org.jboss.Main.(Main.java:187)
      at org.jboss.Main$1.run(Main.java:121)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.Main.main(Main.java:117)
      [Configuration] Could not create MBean DefaultDomain:service=StartUp(example.Startup)
      [Configuration] javax.management.NotCompliantMBeanException: example.StartUp does not implement the example.StartUpMBean interface or the DynamicMBean interface
      [Configuration] at com.sun.management.jmx.Introspector.testCompliance(Introspector.java:130)
      [Configuration] at com.sun.management.jmx.MetaData.testCompliance(MetaData.java:132)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.createMBean(MBeanServerImpl.java:507)
      [Configuration] at org.jboss.configuration.ConfigurationService.create(ConfigurationService.java:340)
      [Configuration] at org.jboss.configuration.ConfigurationService.loadConfiguration(ConfigurationService.java:271)
      [Configuration] at java.lang.reflect.Method.invoke(Native Method)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      [Configuration] at org.jboss.Main.(Main.java:209)
      [Configuration] at org.jboss.Main$1.run(Main.java:121)
      [Configuration] at java.security.AccessController.doPrivileged(Native Method)
      [Configuration] at org.jboss.Main.main(Main.java:117)

      Any ideas?
      Thanks,
      David

        • 1. Re: simple start up service based on mbeans
          Adrian Brock Master

          Hi,

          Put your jar lib/ext

          FYI: V3 has support for hot deploying services in the
          deploy directory.

          Regards,
          Adrian

          • 2. Re: simple start up service based on mbeans
            David Brown Newbie

            Adrian,
            thanks for the advice, the server now seems to pick up the classes okay. There is still something wrong, though. I now get the following complaint:

            javax.management.NotCompliantMBeanException: example.StartUp does not implement the example.StartUpMBean interface or the DynamicMBean interface
            at com.sun.management.jmx.Introspector.testCompliance(Introspector.java:130)
            at com.sun.management.jmx.MetaData.testCompliance(MetaData.java:132)
            at com.sun.management.jmx.MBeanServerImpl.createMBean(MBeanServerImpl.java:759)
            at javax.management.loading.MLet.getMBeansFromURL(MLet.java:540)
            at javax.management.loading.MLet.getMBeansFromURL(MLet.java:369)
            at org.jboss.Main.(Main.java:187)
            at org.jboss.Main$1.run(Main.java:121)
            at java.security.AccessController.doPrivileged(Native Method)
            at org.jboss.Main.main(Main.java:117)
            [Configuration] Could not create MBean DefaultDomain:service=StartUp(example.Startup)
            [Configuration] javax.management.NotCompliantMBeanException: example.StartUp does not implement the example.StartUpMBean interface or the DynamicMBean interface
            [Configuration] at com.sun.management.jmx.Introspector.testCompliance(Introspector.java:130)
            [Configuration] at com.sun.management.jmx.MetaData.testCompliance(MetaData.java:132)
            [Configuration] at com.sun.management.jmx.MBeanServerImpl.createMBean(MBeanServerImpl.java:507)
            [Configuration] at org.jboss.configuration.ConfigurationService.create(ConfigurationService.java:340)
            [Configuration] at org.jboss.configuration.ConfigurationService.loadConfiguration(ConfigurationService.java:271)
            [Configuration] at java.lang.reflect.Method.invoke(Native Method)
            [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
            [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
            [Configuration] at org.jboss.Main.(Main.java:209)
            [Configuration] at org.jboss.Main$1.run(Main.java:121)
            [Configuration] at java.security.AccessController.doPrivileged(Native Method)
            [Configuration] at org.jboss.Main.main(Main.java:117)

            Any ideas?
            Thanks,
            David

            • 3. Re: simple start up service based on mbeans
              Adrian Brock Master

              Hi,

              You're code attribute should be
              example.StartUp.LoggerService

              if you'll need the interface
              example.StartUp.LoggerServiceMBean extends Service
              to access the configurationFile attribute.

              Regards,
              Adrian

              • 4. Re: simple start up service based on mbeans
                Adrian Brock Master

                Sorry,

                Should read extends ServiceMBean

                Regards,
                Adrian

                • 5. Re: simple start up service based on mbeans
                  David Brown Newbie

                  Adrian,
                  thanks, that was one of the missing pieces. I have now created a StartUpService interface which extends ServiceMBean. My actual implementation now extends ServiceMBeanSupport and implements StartUpService.

                  The StartUpService class looks like this:

                  package example;

                  import org.jboss.util.ServiceMBean;

                  public interface StartUpService extends ServiceMBean {
                  public void setPropertyFile(String configurationFile);
                  public String getPropertyFile();
                  }

                  and my implementation looks like this:

                  package example;

                  import org.jboss.util.ServiceMBeanSupport;

                  public class StartUpMBean extends ServiceMBeanSupport implements StartUpService {
                  public void startService(){
                  // configure all my stuff
                  }

                  public void stopService(){
                  }

                  public void setConfigurationFile(String configurationFile){
                  this.configurationFile = configurationFile;
                  }

                  public String getConfigurationFile(){
                  return configurationFile;
                  }

                  public String getName(){
                  return "Start up service";
                  }

                  private String configurationFile;
                  }


                  My XML looks like this:


                  startup.configuration


                  I still can't get it to work, it is now complaining with the following at start up:

                  [Configuration] Could not create MBean DefaultDomain:service=StartUp(example.StartUpMBean)
                  [Configuration] javax.management.NotCompliantMBeanException: example.StartUpMBean does not implement the example.StartUpMBeanMBean interface or the DynamicMBean interface
                  [Configuration] at com.sun.management.jmx.Introspector.testCompliance(Introspector.java:130)
                  [Configuration] at com.sun.management.jmx.MetaData.testCompliance(MetaData.java:132)
                  [Configuration] at com.sun.management.jmx.MBeanServerImpl.createMBean(MBeanServerImpl.java:507)
                  [Configuration] at org.jboss.configuration.ConfigurationService.create(ConfigurationService.java:340)
                  [Configuration] at org.jboss.configuration.ConfigurationService.loadConfiguration(ConfigurationService.java:271)
                  [Configuration] at java.lang.reflect.Method.invoke(Native Method)
                  [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
                  [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
                  [Configuration] at org.jboss.Main.(Main.java:209)
                  [Configuration] at org.jboss.Main$1.run(Main.java:121)
                  [Configuration] at java.security.AccessController.doPrivileged(Native Method)
                  [Configuration] at org.jboss.Main.main(Main.java:117)

                  Any more ideas you have would be much appreciated.
                  Thanks,
                  -David

                  • 6. Re: simple start up service based on mbeans
                    Adrian Brock Master

                    Hi,

                    You've got it the wrong way around :-)

                    It should be

                    interface StartUpServiceMBean
                    extends ServiceMBean

                    class StartUpService
                    extends ServiceMBeanSupport
                    implements StartUpServiceMBean

                    <mbean code="examples.StartUpService" ...

                    The implements StartUpServiceMBean isn't necessary,
                    but it does spot errors at compile time.

                    I'll try to explain it.

                    1) StartUpService is what JBoss registers with JMX it is the implementation of the service.

                    2) JMX looks for StartUpServiceMBean to see which methods/attributes it should instrument.

                    3) ServiceMBean defines the necessary JBoss Service
                    methods available through JMX.

                    4) ServiceMBeanSupport does the spade work for
                    the ServiceMBean methods, you only have to implement
                    startService, stopService, getName and your own methods.

                    Regards,
                    Adrian

                    • 7. Re: simple start up service based on mbeans
                      David Brown Newbie

                      Adrian,
                      I realise now that what you explained is exactly the set-up that I had, except you suggest much more sensible names for the classes and interfaces themselves.

                      The main gotcha which wasn't sinking into my skull was that the name of the interface class (which extends ServiceMBean) was being derived from my implementation class by magically sticking an MBean on the end of its name.

                      If I had simply renamed my original StartUpService interface to StartUpMBeanMBean, then it would have worked. But yuk! The names you suggest are a much better idea.

                      I must say, that on all application servers I have worked on (BEA/WebLogic, IBM/WebSphere, ATG/Dynamo), they don't exactly go out of their way to explain how to do services that start up with the server itself, yet on every project I have had to end up doing one. In my books, that makes it a pretty important thing to document.

                      Anyway, it now works and I cannot thank you enough. You are a God of JBoss!
                      Thanks,
                      David