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

adrian@jboss.org do-not-reply at jboss.com
Tue Feb 5 16:32:02 EST 2008


"adrian at jboss.org" wrote : 
  | And the test passes with the following output on redeploy
  | 

Just for clarification purposes, JBMICROCONT-234 is not required to fix the problem.
The fix is to use the deployment classloader as the initiating classloader.

But I've applied it anyway since it will resolve some other problems.

So a temporary workaround without updating the MC code in trunk would be
to replace the BeanMetaDataDeployer (configured in bootstrap-beans.xml)
with something like:


  | package org.jboss.system.deployers;
  | 
  | import org.jboss.beans.metadata.spi.BeanMetaData;
  | import org.jboss.deployers.spi.DeploymentException;
  | import org.jboss.deployers.structure.spi.DeploymentUnit;
  | import org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer;
  | import org.jboss.kernel.Kernel;
  | 
  | /**
  |  * A version of the POJO deployer that sets the context classloader to the deployment classloader
  |  * 
  |  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  |  * @version $Revision: 1.1 $
  |  */
  | public class TempBeanMetaDataDeployer extends BeanMetaDataDeployer
  | {
  |    public TempBeanMetaDataDeployer(Kernel kernel)
  |    {
  |       super(kernel);
  |    }
  | 
  |    public void deploy(DeploymentUnit unit, BeanMetaData deployment) throws DeploymentException
  |    {
  |       ClassLoader old = Thread.currentThread().getContextClassLoader();
  |       Thread.currentThread().setContextClassLoader(unit.getClassLoader());
  |       try
  |       {
  |          super.deploy(unit, deployment);
  |       }
  |       finally
  |       {
  |          Thread.currentThread().setContextClassLoader(old);
  |       }
  |    }
  | }
  | 

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

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



More information about the jboss-dev-forums mailing list