@Test
public void testDifferentClassLoader() throws Exception
{
URLClassLoader master = (URLClassLoader) Thread.currentThread().getContextClassLoader();
ClassLoader cl = new RedefiningClassLoader(master, MyServiceRemoteBusiness.class, MyService.class, RemoteServiceTestCase.class);
Thread.currentThread().setContextClassLoader(cl);
try
{
System.err.println("X latestUserDefinedLoader = " + Bridge.get().getLatestUserDefinedLoader());
// setup a proper call stack class loader
Class<?> testClass = cl.loadClass(RemoteServiceTestCase.class.getName());
assertEquals(cl, testClass.getClassLoader());
Method testMethod = testClass.getMethod("test1");
Object obj = testClass.newInstance();
testMethod.invoke(obj);
Class<?> intf = cl.loadClass(MyServiceRemoteBusiness.class.getName());
InitialContext ctx = new InitialContext();
Method method = intf.getMethod("getUuid");
System.err.println(method.getDeclaringClass().getClassLoader());
Object bean = ctx.lookup("MyServiceBean/remote");
System.err.println(bean.getClass().getInterfaces()[0].getClassLoader());