[jboss-dev-forums] [Design of POJO Server] - Re: Classloader problem with NamingRestartUnitTestCase

adrian@jboss.org do-not-reply at jboss.com
Tue Feb 5 12:09:55 EST 2008


My guess is that AOP is caching the classloader somewhere?

The most obvious candidate is this code in AOPDependencyBuilder:


  |       AspectManager manager = AspectManagerFactory.getAspectManager(metaData);
  | 

which eventually boils down to a lookup by a String based on the deployment name

AspectManagerFactory

  |    public static AspectManager getAspectManager(MetaData md)
  |    {
  |       AspectManager manager = AspectManager.instance();
  |       if (md != null)
  |       {
  |          ApplicationScope app = md.getMetaData(ApplicationScope.class);
  |          DeploymentScope dep = md.getMetaData(DeploymentScope.class);
  |          if (app != null && dep != null)
  |          {
  |             JBossStringBuilder fqn = new JBossStringBuilder("/");
  |             AspectManager sub = null;
  |             if (app != null)
  |             {
  |                String name="APPLICATION=" + app.value();
  |                fqn.append(name);
  |                fqn.append("/");
  |                sub = manager.findManagerByName(fqn.toString());
  |                if (sub == null)
  |                {
  |                   sub = createNewDomain(manager, name);
  |                }
  |             }
  |             
  |             if (dep != null)
  |             {
  |                String name="DEPLOYMENT=" + dep.value();
  |                fqn.append(name);
  |                fqn.append("/");
  |                AspectManager parent = sub;
  |                sub = manager.findManagerByName(fqn.toString());
  |                if (sub == null)
  |                {
  |                   sub = createNewDomain(parent, name);
  |                }
  |             }
  |             return sub;
  |          }
  |       }
  |       return manager;
  |    }
  | 

AspectManager:

  |    /** A map of domains by name */
  |    protected volatile WeakValueHashMap subDomainsByName = UnmodifiableEmptyCollections.EMPTY_WEAK_VALUE_HASHMAP;
  | 

Although this is a WeakValueHashMap, there's no guarantee that
it will be reaped (depends when the GC runs) between redeployments
and there is no "remove" at undeployment.

So if something in the sub Domain created for the deployment name
references the old classloader, it is going to leak across redeployment.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4126649#4126649

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4126649



More information about the jboss-dev-forums mailing list