Load webapp from the compiled jar file with embedded Tomcat 7

809 Views Asked by At

I usually develop web application using embedded jetty server and wrap them in .exe file using applications like Launcher4j. I like to put my web application folder inside a java package and read it from there instead of putting it in a folder next to the generated .exe file. I like to do so to protect my webapp from being edited. With an embedded jetty server it is done like this:

String jetty_home = MyClass.class.getClassLoader().getResource(webappsClassPath).toExternalForm();
    WebAppContext webapp = new WebAppContext();
    webapp.setServer(server);
    webapp.setContextPath(contextPath);
    webapp.setResourceBase(jetty_home + "/webapps/MyWebapp");
    webapp.setWar(webappsFolder);
    webapp.setParentLoaderPriority(true);

How can I manage the same with an embedded Tomcat 7 or Tomcat 8-alpha server? Thank you! :)

0

There are 0 best solutions below