Uploaded image for project: 'controller'
  1. controller
  2. CONTROLLER-623

ManagementFactory.getPlatformMBeanServer() does not work in karaf

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • Helium
    • None
    • config
    • None
    • Operating System: Mac OS
      Platform: PC

    • 1359

    Description

      This bug was discovered in the context of:

      https://git.opendaylight.org/gerrit/#/c/8963/

      trying to do the Karaf work.

      The shell script that starts karaf on line 410 has
      -Djavax.management.builder.initial=org.apache.karaf.management.boot.KarafMBeanServerBuilder

      This causes the config subsystem to break in karaf due to its many uses of:
      ManagementFactory.getPlatformMBeanServer()
      (see ConfigManagerActivator [line 32] for one of many examples).

      If you
      feature:install odl-config-startup from
      https://git.opendaylight.org/gerrit/#/c/8963/
      in karaf (to launch karaf:
      cd controller/opendaylight/distribution/opendaylight-karaf/;mvn clean install;cd target/;unzip -o controller/opendaylight/distribution/opendaylight-karaf/target/distribution.opendaylight-karaf-1.4.2-SNAPSHOT.zip; cd distribution.opendaylight-karaf-1.4.2-SNAPSHOT/bin;./karaf
      )

      You will get an exception like the one in the attachment. This is rooted in karaf JMX RBAC as enforced by the:
      -Djavax.management.builder.initial=org.apache.karaf.management.boot.KarafMBeanServerBuilder

      This can be solved in two ways:

      1) Remove from the bin/karaf the
      -Djavax.management.builder.initial=org.apache.karaf.management.boot.KarafMBeanServerBuilder
      Disadvantage: It means that if folks try to install us in a normal karaf container there will still be breakage... this is a non-standard way to customize karaf.

      2) Write a ConfigManagementFactory with a getPlatformMBeanServer() that does
      the right thing in Karaf and just passes through to ManagementFactory.getPlatformMBeanServer() everywhere else. Replace all of our uses of ManagementFactory.getPlatformMBeanServer() with
      ConfigManagementFactory.getPlatformMBeanServer().

      Note... the right thing for karaf looks something like:

      Map<String,String> h = new HashMap<String,String>();
      h.put(Context.SECURITY_PRINCIPAL, “karaf");
      h.put(Context.SECURITY_CREDENTIALS, “karaf");

      JMXConnector connector = JMXConnectorFactory.connect(serviceURL, h);
      MBeanServerConnection con = connector.getMBeanServerConnection();
      Where obviously rather than hardcode the username and password, we read them from properties.
      http://karaf.apache.org/manual/latest/users-guide/monitoring.html gives you the URL, though it should also not
      be hardcoded but rather obtained using ConfigAdmin service and load the org.apache.karaf.management config PID. Care should be taken to do this in a way that
      does not break if run in our old container.
      Disadvantage: Its work, but I don't think a lot of work.

      Attachments

        1. pastebin
          8 kB
          eaw@cisco.com
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            hagbard Ed Warnicke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: