glassfish
  1. glassfish
  2. GLASSFISH-430

Problem with registering an MBean that implements MBeanRegistration Interface

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 9.0pe
    • Fix Version/s: 9.0pe
    • Component/s: admin
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      430

      Description

      Implement MBeanRegistration Interface in an MBean with class say
      "com.example.Foo". (Attached are classes and Sources).

      Copy the class bits at <applications/mbeans>

      Now register that MBean as: create-mbean com.example.Foo

      (Surprisingly, if I say create-mbean --objectname user:foo=bar com.example.Foo,
      it works!)

      Get following exception:

      Caused by: java.lang.RuntimeException: java.lang.RuntimeException:
      java.lang.RuntimeException: While
      registering, the configured object-name:
      :type=dont-compare-object-name,server=server and the actua
      l object-name: DefaultDomain:type=dont-compare-object-name,server=server must be
      the same
      at
      com.sun.enterprise.admin.mbeans.custom.MBeanValidator.registerTestMBean(MBeanValidator.ja
      va:68)
      at
      com.sun.enterprise.admin.mbeans.custom.BasicCustomMBeanOperations.selectObjectName(BasicC
      ustomMBeanOperations.java:217)
      at
      com.sun.enterprise.admin.mbeans.custom.BasicCustomMBeanOperations.createMBeanDefinitionIn
      Domain(BasicCustomMBeanOperations.java:191)
      at
      com.sun.enterprise.admin.mbeans.custom.BasicCustomMBeanOperations.createMBeanDefinitionAd
      dingReferenceToServer(BasicCustomMBeanOperations.java:168)
      ... 49 more
      Caused by: java.lang.RuntimeException: java.lang.RuntimeException: While
      registering, the configured
      object-name: :type=dont-compare-object-name,server=server and the actual
      object-name: DefaultDomain
      :type=dont-compare-object-name,server=server must be the same
      at
      com.sun.enterprise.admin.mbeans.custom.loading.CustomMBeanRegistrationImpl.registerMBean(
      CustomMBeanRegistrationImpl.java:143)
      at
      com.sun.enterprise.admin.mbeans.custom.MBeanValidator.registerTestMBean(MBeanValidator.ja
      va:65)
      ... 52 more
      Caused by: java.lang.RuntimeException: While registering, the configured
      object-name: :type=dont-com
      pare-object-name,server=server and the actual object-name:
      DefaultDomain:type=dont-compare-object-na
      me,server=server must be the same
      at
      com.sun.enterprise.admin.mbeans.custom.loading.CustomMBeanRegistrationImpl.registerMBean(
      CustomMBeanRegistrationImpl.java:110)
      ... 53 more

      CLI137 Command create-mbean failed.

        Activity

        Hide
        km105526 added a comment -

        Created an attachment (id=149)
        zip file

        Show
        km105526 added a comment - Created an attachment (id=149) zip file
        Hide
        km105526 added a comment -

        Please see the ObjectName comparison.

        Show
        km105526 added a comment - Please see the ObjectName comparison.
        Hide
        Byron Nevins added a comment -

        getCascadingAwareObjectName() returns this for the object-name:
        ":server=server,type=dont-compare-object-name"

        The object name returned by mbs.registerMBean(mo, on):
        "DefaultDomain:server=server,type=dont-compare-object-name"

        The object names are supposed to match.

        Show
        Byron Nevins added a comment - getCascadingAwareObjectName() returns this for the object-name: ":server=server,type=dont-compare-object-name" The object name returned by mbs.registerMBean(mo, on): "DefaultDomain:server=server,type=dont-compare-object-name" The object names are supposed to match.
        Hide
        Byron Nevins added a comment -

        Problem: TEST_OBJECT_NAME_DONT_COMPARE is used as the object name for CMBs that
        implement MBeanRegistration. TEST_OBJECT_NAME_DONT_COMPARE didn't have a domain
        name. So MBS added one ("DefaultDomain").

        The fix is simply to add "user" as the domain name.

        Here is the change:

        • TEST_OBJECT_NAME_DONT_COMPARE = new
          ObjectName(":type=dont-compare-object-name");
          + TEST_OBJECT_NAME_DONT_COMPARE = new ObjectName(CUSTOM_MBEAN_DOMAIN
          + ":type=dont-compare-object-name"
        Show
        Byron Nevins added a comment - Problem: TEST_OBJECT_NAME_DONT_COMPARE is used as the object name for CMBs that implement MBeanRegistration. TEST_OBJECT_NAME_DONT_COMPARE didn't have a domain name. So MBS added one ("DefaultDomain"). The fix is simply to add "user" as the domain name. Here is the change: TEST_OBJECT_NAME_DONT_COMPARE = new ObjectName(":type=dont-compare-object-name"); + TEST_OBJECT_NAME_DONT_COMPARE = new ObjectName(CUSTOM_MBEAN_DOMAIN + ":type=dont-compare-object-name"
        Hide
        Byron Nevins added a comment -

        There are 2 different places that compare our generated ON with the ON that MBS
        returns. One of these places doesn't do the check if the CMB implements
        MBeanRegistration. The other does:

        BasicCustomMBeanOperations.selectObjectName() does the check
        CustomMBeanRegistrationImpl.registerMBean() does not do the check

        The second method will ALWAYS error out in the course of create-mbean if the CMB
        changes the object-name itself.
        A possible fix for this is to NOT compare if the CMB implements
        MBeanRegistration. Then use the MBS returned ON as the official saved ON.

        Show
        Byron Nevins added a comment - There are 2 different places that compare our generated ON with the ON that MBS returns. One of these places doesn't do the check if the CMB implements MBeanRegistration. The other does: BasicCustomMBeanOperations.selectObjectName() does the check CustomMBeanRegistrationImpl.registerMBean() does not do the check The second method will ALWAYS error out in the course of create-mbean if the CMB changes the object-name itself. A possible fix for this is to NOT compare if the CMB implements MBeanRegistration. Then use the MBS returned ON as the official saved ON.
        Show
        km105526 added a comment - This has been fixed. Directory: /glassfish/admin/mbeans/src/java/com/sun/enterprise/admin/mbeans/custom/ =================================================================================== File [changed] : BasicCustomMBeanOperations.java Url: https://glassfish.dev.java.net/source/browse/glassfish/admin/mbeans/src/java/com/sun/enterprise/admin/mbeans/custom/BasicCustomMBeanOperations.java?r1=1.15&r2=1.16 File [changed] : CustomMBeanConstants.java Url: https://glassfish.dev.java.net/source/browse/glassfish/admin/mbeans/src/java/com/sun/enterprise/admin/mbeans/custom/CustomMBeanConstants.java?r1=1.6&r2=1.7 File [changed] : ObjectNameSelectionAlgorithm.java Url: https://glassfish.dev.java.net/source/browse/glassfish/admin/mbeans/src/java/com/sun/enterprise/admin/mbeans/custom/ObjectNameSelectionAlgorithm.java?r1=1.3&r2=1.4 File [changed] : CustomMBeanRegistrationImpl.java Url: https://glassfish.dev.java.net/source/browse/glassfish/admin/mbeans/src/java/com/sun/enterprise/admin/mbeans/custom/loading/CustomMBeanRegistrationImpl.java?r1=1.9&r2=1.10

          People

          • Assignee:
            Byron Nevins
            Reporter:
            km105526
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: