/** * Override to apply the equivalent of the stock "$CATALINA_BASE/conf/web.xml" to contexts * programmatically. */ @Override protected synchronized void beforeStart() { super.beforeStart(); ((SipStandardContext) context) .setJ2EEServer("MSS-Arquillian-7-" + UUID.randomUUID().toString()); Tomcat.initWebappDefaults(context); };
public static void main(String[] args) throws Exception { final Tomcat tomcat = new Tomcat(); tomcat.setBaseDir("."); // location where temp dir is created tomcat.setPort(8080); // configure context final File applicationPath = new File("./webapp"); // todo: change to your location Context rootContext = tomcat.addContext("/", "C:\\Users\\Ali\\git\\finder\\finder\\src\\main\\webapp"); rootContext.addLifecycleListener(new ContextConfig()); // JSP and Default Servlet setup, mime type mapping and welcome files Tomcat.initWebappDefaults(rootContext); // start server tomcat.start(); tomcat.getServer().await(); }
/** * Provide default configuration for a context. This is the programmatic equivalent of the default * web.xml. * * <p>TODO: in normal Tomcat, if default-web.xml is not found, use this method * * @param contextPath The context to set the defaults for */ public void initWebappDefaults(String contextPath) { Container ctx = getHost().findChild(contextPath); initWebappDefaults((Context) ctx); }