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

MBean created via EAR/META-INF/jboss-service.xml from class defined in JBoss module gets wrong TCCL

XMLWordPrintable

    • Hide

      (See attached archive for reproducer)
      1. Create a JBoss module w/ an MBean, deploy to JBOSS_HOME/modules/foo.
      2. Reference the module as a global-module in standalone.xml's ee subsystem to grant access MBean from EAR deployments.
      3. Create EAR with META-INF/jboss-service.xml which references the MBean.
      4. Attempt to classload resources present in EAR/META-INF.

      Show
      (See attached archive for reproducer) 1. Create a JBoss module w/ an MBean, deploy to JBOSS_HOME/modules/foo. 2. Reference the module as a global-module in standalone.xml's ee subsystem to grant access MBean from EAR deployments. 3. Create EAR with META-INF/jboss-service.xml which references the MBean. 4. Attempt to classload resources present in EAR/META-INF.

      When an MBean is loaded from jboss-service.xml within an EAR, the TCCL should point to the EAR deployment so that config files and other resources can be classloaded from the EAR. Under JBoss 7.1.1.Final, the TCCL in a module loaded MBean's start() method is the module's ClassLoader. No reference to the EAR deployment's classloader is available, thus EAR resources are not available within the MBean.

      It appears that org.jboss.as.service.AbstractService::invokeLifecycleMethod() incorrectly sets the TCCL to the module's defining classloader rather than the EAR's:

      {{{
      protected void invokeLifecycleMethod(final Method method) throws InvocationTargetException, IllegalAccessException {
      if (method != null) {
      final ClassLoader old = SecurityActions.setThreadContextClassLoader(mBeanInstance.getClass().getClassLoader());
      try

      { method.invoke(mBeanInstance); }

      finally

      { SecurityActions.resetThreadContextClassLoader(old); }

      }
      }
      }}}

            jaikiran Jaikiran Pai (Inactive)
            zbedell_jira Zachary Bedell (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: