4 Replies Latest reply on Aug 14, 2003 7:44 AM by tanja

    Can't find MBeanServer

    tanja

      Hello,

      I'm very new at JBoss and MBEans ans suchs things.

      I try to acess the DestinationManager MBean from My Code, but I can't find the MBeanServer.

      ArrayList servers = MBeanServerFactory.findMBeanServer(null);
      if (servers == null) {
      throw new Exception("No MBeanServer found.");
      }
      else {
      MBeanServer server = (MBeanServer) servers.get(0);
      ObjectName on = new ObjectName("jboss:service=DestinationManager");
      String[] param = {
      "TanjaQueue", "tanja"};
      String[] sig = {
      "java.lang.String", "java.lang.String"};
      server.invoke(on, "destroyQueue", param, sig);
      }

      If I try to run it, I get an IndexOutOfBoundsException: Index: 0, Size: 0, the Array List has the size 0.

      Can anyone help me please?

        • 1. Re: Can't find MBeanServer
          sradford

          Where is this code running?

          And I presume that the line number of the IndexOutOfBoundsException is the MBeanServer server = (MBeanServer) servers.get(0); line?

          • 2. Re: Can't find MBeanServer
            sradford

            Also...

            Not used any of the Java Messaging stuff, but shouldn't the domain name of your MBean you're calling be 'jboss.mq' and not just 'jboss'?

            • 3. Re: Can't find MBeanServer
              tanja

              Your right, in both cases.

              My final achieve was to write my own MBean to create Queues, but if I try to invoke my 'createNewQueue'-method from the jmx console, I get the error:

              HTTP ERROR: 500 Failed to invoke operation
              RequestURI=/jmx-console/HtmlAdaptor

              So I tried to run my method in a standalone client, so I cannot find an MBean server, clear...

              But whats wrong with my MBean?

              • 4. Re: Can't find MBeanServer
                tanja

                Finally I managed it, it works!
                I simply tried to invoke the wrong method 'destroyQueue' instead of 'createQueue'...
                I confused myself with a lot of different test ;-)

                Thanks for your help!
                Greetings Tanja