Community

ClassPoolRepository vs JBossclDelegatingClassPoolRepository

created by Flavia Rainone in JBoss Microcontainer Development - View the full discussion

Since we updated the classpool and AOP versions at JBoss AS, we've been seeing some warning messages showing that unregistering of ClassPool is not working correctly.

The reason for these failures is that AspectManager is using ClassPoolRepository to register ClassLoaders, whereas the unregistering of ClassLoaders, performed by RegisterModuleCallback, is using JBossClDelegatingClassPoolRepository. As JBossClDelegatingClassPoolRepository.registeredModules map lacks the the register info, unregisterClassLoader is throwing an exception:

 

 

   public void unregisterClassLoader(ClassLoader classLoader, Module module)
   {
      ScopedClassPool classPool = registeredModules.remove(module);
      if (classLoader == null)
      {
         if (classPool == null)
         {
            throw new IllegalStateException("Module " + module + " is not registered");
         }

 

So, to fix this, AspectManager must start using JBossClDelegatingClassPoolFactory instead of ClassPoolFactory:

 

   public ClassPool registerClassLoader(ClassLoader ucl)
   {
      return ClassPoolRepository.getInstance().registerClassLoader(ucl);
   }

 

But this cannot be hard coded because JBossClDelegatingClassPoolFactory provides support to modules and assumes that you are using jboss-cl, which is only true in AS 5/6 environment. When using JBoss AOP in standalone mode or in JBoss AS 4, we need to use ClassPoolRepository.

 

The way that the ClassPool architecture is today, I'll have to make this configurable on the AOP side (e.g., I'll probably add this to AspectManagerJDK5). Is this the best option? Or should we rethink ClassPool architecture, making this configurable on the ClassPool side?

Reply to this message by going to Community

Start a new discussion in JBoss Microcontainer Development at Community