2 Replies Latest reply on Jan 29, 2009 9:54 AM by Adrian Brock

    Finding RealClassLoader in ServiceDeployer

    Ales Justin Master

      There was this fix mentioned here:
      - http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4132644#4132644

      I have a patch ready:

      Index: system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java
      ===================================================================
      --- system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java (revision 83578)
      +++ system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java Thu Jan 29 10:12:22 CET 2009
      @@ -84,13 +84,7 @@
       {
       ObjectName loaderName = deployment.getClassLoaderName();
       if (loaderName == null)
      - {
      - ClassLoader cl = unit.getClassLoader();
      - if (cl != null && cl instanceof RealClassLoader)
      - loaderName = ((RealClassLoader) cl).getObjectName();
      - else
      - loaderName = defaultClassLoader;
      - }
      + loaderName = findLoaderName(unit.getClassLoader());
      
       controller.install(deployment, loaderName);
       ServiceContext context = controller.getServiceContext(name);
      @@ -124,6 +118,28 @@
       }
       }
      
      + /**
      + * Find first RealClassLoader instance
      + * and return its ObjectName.
      + * If none is found return defaultClassloader.
      + *
      + * @param cl the classloader
      + * @return classloader's ObjectName
      + */
      + protected ObjectName findLoaderName(ClassLoader cl)
      + {
      + if (cl == null)
      + return defaultClassLoader;
      +
      + if (cl instanceof RealClassLoader)
      + {
      + RealClassLoader rcl = RealClassLoader.class.cast(cl);
      + return rcl.getObjectName();
      + }
      +
      + return findLoaderName(cl.getParent());
      + }
      +
       public void undeploy(DeploymentUnit unit, ServiceMetaData deployment)
       {
       ObjectName name = deployment.getObjectName();
      


      Should I apply it?
      Or it might have some strange side affect? :-)

        • 1. Re: Finding RealClassLoader in ServiceDeployer
          Ales Justin Master

          I see ThomasD already applied my patch to 5_0:

          Modified:
           branches/Branch_5_0/system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java
          Log:
          [JBAS-6425] full hirarcy search for RealClassLoader
          


          And I doubt (I actually know he didn't :-)) he ran all the tests
          or waited for Hudson to puke some error.

          Ccccc Thomas ... too global change to not let it pass some testing before commit. ;-)

          • 2. Re: Finding RealClassLoader in ServiceDeployer
            Adrian Brock Master

            The hierarchy search is just a hack for lazy users.

            Thomas should be passing in the RealClassLoader in the first place,
            i.e. the (sub-)deployment classloader.

            The one he was actually passing in is the wrapper ejb classloader which
            has other side affects like it is associated with the EJB's enc when used as the context classloader.

            This "fix" corrects the problem for JMX but not for other uses of that "deployment"
            classloader.