Code example for URLClassLoader

0
    } 
 
    @Test 
    public void testNonDefaultClassLoader() throws Exception { 
 
        ClassLoader cl = new URLClassLoader(new URL[0],
                Thread.currentThread().getContextClassLoader());
 
        Thread.currentThread().setContextClassLoader(cl);
 
        Tomcat tomcat = getTomcatInstance();
        tomcat.getServer().setParentClassLoader(cl);
 
        // Must have a real docBase - just use temp 
        Context ctx =
            tomcat.addContext("", System.getProperty("java.io.tmpdir"));
 
        Tomcat.addServlet(ctx, "ClassLoaderReport", new ClassLoaderReport(cl));
        ctx.addServletMapping("/", "ClassLoaderReport");
 
        tomcat.start();