2 Replies Latest reply on Dec 5, 2008 8:00 AM by Adrian Brock

    NPE  in CLSpace

    Ales Justin Master

      DML found this NPE in CLSpace:
      - http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4194484#4194484

      Take this three config files

      <classloading name="jboss-threads-classloader" version="1.0.0.Alpha" xmlns="urn:jboss:classloading:1.0">
       <capabilities>
       <module name="jboss-threads" version="1.0.0.Alpha"/>
       <package name="org.jboss.threads" version="1.0.0.Alpha"/>
       </capabilities>
       <requirements/>
      </classloading>
      
      <classloading name="jboss-threads-deployer-classloader" version="1.0.0.Alpha" xmlns="urn:jboss:classloading:1.0">
       <requirements>
       <module name="jboss-threads"/>
       <package name="org.jboss.deployers.vfs.deployer.kernel"/>
       <package name="org.jboss.deployers.vfs.spi.deployer"/>
       </requirements>
      </classloading>
      
      <classloading name="jboss-kernel-classloader" version="2.0.0.GA" xmlns="urn:jboss:classloading:1.0" import-all="true">
       <capabilities>
       <package name="org.jboss.deployers.vfs.deployer.kernel"/>
       <package name="org.jboss.deployers.vfs.spi.deployer"/>
       </capabilities>
       <requirements/>
      </classloading>
      

      And you end up with
      JBoss-MC-Demo ERROR [04-12-2008 23:56:08] AbstractKernelController - Error resolving dependencies for ClassLoader: name=vfsfile:/C:/projects/demos/sandbox/deployers/ state=Describe mode=Manual requiredState=ClassLoader
      java.lang.NullPointerException
       at org.jboss.classloading.spi.dependency.ClassLoadingSpace.resolve(ClassLoadingSpace.java:325)
       at org.jboss.classloading.spi.dependency.ClassLoadingSpace.joinAndResolve(ClassLoadingSpace.java:122)
       at org.jboss.classloading.spi.dependency.ClassLoadingSpace.joinAndResolve(ClassLoadingSpace.java:169)
       at org.jboss.classloading.spi.dependency.ClassLoadingSpace.resolve(ClassLoadingSpace.java:325)
       at org.jboss.classloading.spi.dependency.Module.resolveModule(Module.java:737)
       at org.jboss.classloading.spi.dependency.RequirementDependencyItem.resolve(RequirementDependencyItem.java:87)
       at org.jboss.dependency.plugins.AbstractDependencyInfo.resolveDependencies(AbstractDependencyInfo.java:143)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1103)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1039)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
       at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:545)
       at org.jboss.demos.bootstrap.MainDeployerHelper.process(MainDeployerHelper.java:86)
      


      The cause is the CLMD/module with import-all="true" and this code in Domain::addModule
       // Skip the classloader space checking when it is import all
       if (module.isImportAll() == false)
       {
       ClassLoadingSpace space = new ClassLoadingSpace();
       space.join(module);
       }
      

      Module never joins any CLSpace.

        • 1. Re: NPE  in CLSpace
          Adrian Brock Master

           

          "alesj" wrote:

          And you end up with
          JBoss-MC-Demo ERROR [04-12-2008 23:56:08] AbstractKernelController - Error resolving dependencies for ClassLoader: name=vfsfile:/C:/projects/demos/sandbox/deployers/ state=Describe mode=Manual requiredState=ClassLoader
          java.lang.NullPointerException
           at org.jboss.classloading.spi.dependency.ClassLoadingSpace.resolve(ClassLoadingSpace.java:325)
           at org.jboss.classloading.spi.dependency.ClassLoadingSpace.joinAndResolve(ClassLoadingSpace.java:122)
           at org.jboss.classloading.spi.dependency.ClassLoadingSpace.joinAndResolve(ClassLoadingSpace.java:169)
           at org.jboss.classloading.spi.dependency.ClassLoadingSpace.resolve(ClassLoadingSpace.java:325)
           at org.jboss.classloading.spi.dependency.Module.resolveModule(Module.java:737)
           at org.jboss.classloading.spi.dependency.RequirementDependencyItem.resolve(RequirementDependencyItem.java:87)
           at org.jboss.dependency.plugins.AbstractDependencyInfo.resolveDependencies(AbstractDependencyInfo.java:143)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1103)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1039)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
           at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:545)
           at org.jboss.demos.bootstrap.MainDeployerHelper.process(MainDeployerHelper.java:86)
          


          The cause is the CLMD/module with import-all="true" and this code in Domain::addModule
           // Skip the classloader space checking when it is import all
           if (module.isImportAll() == false)
           {
           ClassLoadingSpace space = new ClassLoadingSpace();
           space.join(module);
           }
          

          Module never joins any CLSpace.


          The NPE is obviously a bug, but the import-all not taking part in the ClassloadingSpace
          checking is correct.

          When you have import-all=true you can't really check consistency
          because the imports are not deterministic.
          i.e. you import everything so there is no way for it know what you actually import.

          The fix looks fairly trivial?
           Module otherModule = module.resolveModule(dependency, false);
           if (otherModule != null)
           {
           // Do we need to join with another classloading space?
           ClassLoadingSpace space = otherModule.getClassLoadingSpace();
          - if (this != space)
          + if (space != null && this != space)
           space.joinAndResolve(this);
           }
          


          But we probably also want to log a warning if one of our explicit imports
          resolves to a module with import-all=true? i.e. the resolved module has
          no classloading space.