ctx.setParentClassLoader(EmbeddedTomcatTestBase.class.getClassLoader());
ctx.setParentClassLoader(classLoader);
context.setParentClassLoader(tomcatParentClassLoader);
private void initServer() { if (tomcat == null) { tomcat = new Tomcat(); } WebConf webConf = ConfigFactory.load(WebConf.class); File baseDir = new File(ConfigFactory.load(CoreConf.class).getBaseTempDir(), Tomcat.class.getSimpleName()); File docBase = new File(baseDir, Context.class.getSimpleName()); checkDir(baseDir, docBase); tomcat.setBaseDir(baseDir.getAbsolutePath()); Host host = tomcat.getHost(); host.setAutoDeploy(false); Context ctx = tomcat.addWebapp(host, webConf.getContextPath(), docBase.getAbsolutePath(), new FatJarContextConfig()); ctx.setJarScanner(new FatJarScanner()); ctx.setParentClassLoader(getClass().getClassLoader()); ctx.addLifecycleListener(new FatJarWebXmlListener()); tomcat.setPort(webConf.getPort()); TomcatConf tomcatConf = ConfigFactory.load(TomcatConf.class); configConnector(tomcat.getConnector(), tomcatConf); configEngine(tomcat.getEngine(), tomcatConf); }
context.setParentClassLoader( getTomcatClassLoader() );
context.setParentClassLoader( getTomcatClassLoader() );
context.setParentClassLoader( getTomcatClassLoader() );
public static void main(String[] args) throws ServletException, LifecycleException, IOException { String hostName = "localhost"; int port = 8080; String contextPath = ""; String tomcatBaseDir = TomcatUtil.createTempDir("tomcat", port).getAbsolutePath(); String contextDocBase = TomcatUtil.createTempDir("tomcat-docBase", port).getAbsolutePath(); Tomcat tomcat = new Tomcat(); tomcat.setBaseDir(tomcatBaseDir); tomcat.setPort(port); tomcat.setHostname(hostName); Host host = tomcat.getHost(); Context context = tomcat.addWebapp(host, contextPath, contextDocBase, new EmbededContextConfig()); context.setJarScanner(new EmbededStandardJarScanner()); ClassLoader classLoader = Main.class.getClassLoader(); context.setParentClassLoader(classLoader); // context load WEB-INF/web.xml from classpath context.addLifecycleListener(new WebXmlMountListener()); tomcat.start(); tomcat.getServer().await(); } }
if (ldr == null) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ctx.setParentClassLoader(classLoader); WebappLoader wldr = new WebappLoader(classLoader);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ctx.setParentClassLoader(classLoader);