4 Replies Latest reply on Dec 17, 2009 12:48 PM by Ales Justin

    Testing ClassPools on AS Trunk

    Flavia Rainone Master

      I am testing jboss-classpool/jboss-aop (branch classpool_JBAOP-742) on AS trunk.

       

      Most of JBoss AOP tests pass, but I'm seeing one failure: NotFoundException for org.jboss.system.Service.

       

      The cause of this problem is that RegisterModuleCallback is added as a ModuleRegistry to ClassLoading after module "bootstrap-classloader:0.0.0$MODULE"

      has been loaded. As a result, a ClassPool is not created for that module and hence, default domain can't find the Service class.

       

      Any ideas on how to solve this problem?

        • 1. Re: Testing ClassPools on AS Trunk
          Flavia Rainone Master

          flavia.rainone@jboss.com wrote:

           

          The cause of this problem is that RegisterModuleCallback is added as a ModuleRegistry to ClassLoading after module "bootstrap-classloader:0.0.0$MODULE"

          has been loaded.

           

          Just an extra piece of info: RegisterModuleCallback is declared as AOPRegisterModuleCallback in server/all/conf/bootstrap/aop.xml. This is what my aop.xml file looks like:

           

          <deployment xmlns="urn:jboss:bean-deployer:2.0">
          
             <classloader><inject bean="aop-classloader:0.0.0"/></classloader>
          
             <classloader name="aop-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="true">
                <root>${jboss.lib.url}jboss-aop-asintegration-core.jar</root>
                <root>${jboss.lib.url}jboss-aop-asintegration-mc.jar</root>
                <root>${jboss.lib.url}jboss-aop-deployers.jar</root>
                <root>${jboss.lib.url}jboss-aop-jboss5.jar</root>
                <root>${jboss.lib.url}jboss-classpool.jar</root>
                <root>${jboss.lib.url}jboss-classpool-jbosscl.jar</root>
             </classloader>
          
             <!-- Integration -->
             <bean name="AOPClassLoaderScopingPolicy" class="org.jboss.aop.asintegration.jboss5.VFSClassLoaderScopingPolicy"/>
          
             <bean name="AOPClassPoolFactory" class="org.jboss.classpool.plugins.jbosscl.JBossClDelegatingClassPoolFactory">
                <constructor>
                   <parameter><inject bean="AOPClassLoaderScopingPolicy" property="registry"/></parameter>
                   <parameter><inject bean="AOPRegisterModuleCallback"/></parameter>
                </constructor>
             </bean>
          
             <bean name="AOPJBossIntegration" class="org.jboss.aop.asintegration.jboss5.JBoss5Integration">
                <property name="classPoolFactory"><inject bean="AOPClassPoolFactory"/></property>
                <property name="aopClassLoaderScopingPolicy"><inject bean="AOPClassLoaderScopingPolicy"/></property>
             </bean>
          
             <bean name="DefaultAspectManager" class="org.jboss.aop.microcontainer.beans.metadata.DefaultAspectManager">
                <property name="managerBean">AspectManager</property>
                <property name="managerProperty">aspectManager</property>
             </bean>
          
             <bean name="ClassLoaderScopingPolicy" class="org.jboss.aop.asintegration.jboss5.AOPVFSClassLoaderDomainRegistry">
               <constructor factoryMethod="getInstance"/>
             </bean>
          
             <bean name="AOPRegisterModuleCallback" class="org.jboss.classpool.plugins.jbosscl.RegisterModuleCallback">
                <constructor>
                  <parameter><inject bean="ClassLoaderScopingPolicy"/></parameter>
                </constructor>
                <install method="addModuleRegistry" bean="ClassLoading" whenRequired="Start">
                   <parameter><this/></parameter>
                </install>
                <uninstall method="removeModuleRegistry" bean="ClassLoading" whenRequired="Start">
                   <parameter><this/></parameter>
                </uninstall>
             </bean>
          
             <!--
                Valid values for the AspectManager bean for use with enableTransformer=true are:
                * org.jboss.aop.deployers.AspectManagerJDK5 - works with the -javaagent:pluggable-instrumentor.jar switch
                * org.jboss.aop.deployers.AspectManagerJRockit - works with JRockit and the -Xmanagement:class=org.jboss.aop.hook.JRockitPluggableClassPreProcessor switch
             -->
             <bean name="AspectManager" class="org.jboss.aop.deployers.AspectManagerJDK5">
                ... 
             </bean>
          
          </deployment>
          
          • 2. Re: Testing ClassPools on AS Trunk
            Ales Justin Master

            flavia.rainone@jboss.com wrote:

             

            I am testing jboss-classpool/jboss-aop (branch classpool_JBAOP-742) on AS trunk.

             

            Most of JBoss AOP tests pass, but I'm seeing one failure: NotFoundException for org.jboss.system.Service.

             

            The cause of this problem is that RegisterModuleCallback is added as a ModuleRegistry to ClassLoading after module "bootstrap-classloader:0.0.0$MODULE"

            has been loaded. As a result, a ClassPool is not created for that module and hence, default domain can't find the Service class.

             

            Any ideas on how to solve this problem?

            What about if you would explicitly create a classpool for that classloader?

             

            That classloader is a bean, and you could inject it into some util/helper which would create the classpool.

            Perhaps you can just add this helper method to RegisterModuleCallback.

            • 3. Re: Testing ClassPools on AS Trunk
              Flavia Rainone Master

              alesj wrote:

               

              What about if you would explicitly create a classpool for that classloader?

               

              That classloader is a bean, and you could inject it into some util/helper which would create the classpool.

              Perhaps you can just add this helper method to RegisterModuleCallback.

               

              That solves my problem. I don't even have to create a new method. I added an incallback method for invoking addModule method passing as a parameter the bootstrap-classloader module bean.
              • 4. Re: Testing ClassPools on AS Trunk
                Ales Justin Master
                I added an incallback method for invoking addModule method passing as a parameter the bootstrap-classloader module bean.

                You should not add incallback but install.

                Otherwise we have 2 incallbacks matching Module -- one is already on ClassLoading bean.

                 

                   public List<BeanMetaData> getBeans()
                   {
                      // Determine some properties
                      String contextName = getContextName();
                      if (contextName == null)
                         contextName = getName() + ":" + getVersion();
                      String moduleName = contextName + "$MODULE";
                      
                      // Create the module
                      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(moduleName, getModuleClass().getName());
                      builder.addConstructorParameter(VFSClassLoaderFactory.class.getName(), this);
                      builder.addConstructorParameter(String.class.getName(), moduleName);
                      builder.addPropertyMetaData("roots", roots);
                      builder.setNoClassLoader();
                      builder.addUninstall("removeClassLoader");
                      BeanMetaData module = builder.getBeanMetaData();
                      
                      // Create the classloader
                      builder = BeanMetaDataBuilder.createBuilder(contextName, ClassLoader.class.getName());
                      builder.setNoClassLoader();
                      builder.setFactory(moduleName);
                      builder.setFactoryMethod("registerClassLoaderPolicy");
                      builder.addConstructorParameter(ClassLoaderSystem.class.getName(), builder.createInject(classLoaderSystemName));
                      BeanMetaData classLoader = builder.getBeanMetaData();
                      
                      return Arrays.asList(classLoader, module);
                   }
                
                

                These are the two beans that get created from classloader element.

                 

                Just add install on RegisterModuleCallback for the boostrap-classloader$MODULE bean.