Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-914

TcclMBeanServer uses wrong classloader

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Major Major
    • None
    • None
    • JMX
    • None
    • Hide

      1) Create a module that exports an MBean class.
      2) Create a 2nd module that deploys that MBean.
      3) Try to invoke a method on the MBean that requires a classloading request from (2)'s module classloader that is not visible from (1).
      4) It will fail because it is using (1)'s classloader.

      Show
      1) Create a module that exports an MBean class. 2) Create a 2nd module that deploys that MBean. 3) Try to invoke a method on the MBean that requires a classloading request from (2)'s module classloader that is not visible from (1). 4) It will fail because it is using (1)'s classloader.

      There is an MBeanServer implementation org.jboss.as.jmx.tcl.TcclMBeanServer that attempts to implement the classloader switching for MBeans found in jboss6 and before.

      However it uses the wrong classloader.

      It uses "PlatformMBeanServer".getClassLoaderFor(ObjectName) of the mbean as the classloader.

      This is not the classloader passed to createBean(), i.e. the deployment's classloader, it is the classloader where the MBean was loaded from, they are not necessarily the same.

      This means classes in the deployment will not be visible for invocations on the mbean unless the place where the mbean class is defined is either the same classloader (this will be true in most cases) or it happens to import the deployment's classloader (very unlikely).

      There is a related issue in that because getClassLoaderFor() is no longer correct, deserialisation of requests using the jmx remote connector won't work for classes passed over the wire that are in the deployment.

      Finally, because TcclMBeanServer is not built using an MBeanServerBuilder, it can't be the platform MBeanServer, which means tools like jconsole wont use it and the classloader will be wrong for those requests.

              Unassigned Unassigned
              warjort_jira Adrian Brock (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: