Java Code Examples for org.jboss.shrinkwrap.api.spec.WebArchive#setWebXML()

The following examples show how to use org.jboss.shrinkwrap.api.spec.WebArchive#setWebXML() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
static void enrichTomcatWithCdi(WebArchive archive) {
    String contextXml = "<Context>\n" +
        "   <Resource name=\"BeanManager\" \n" +
        "      auth=\"Container\"\n" +
        "      type=\"javax.enterprise.inject.spi.BeanManager\"\n" +
        "      factory=\"org.jboss.weld.resources.ManagerObjectFactory\"/>\n" +
        "</Context>\n";

    String webXml = "<web-app version=\"3.0\">\n" +
        "<listener>\n" +
        "      <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>\n" +
        "   </listener>" +
        "  <resource-env-ref>\n" +
        "    <resource-env-ref-name>BeanManager</resource-env-ref-name>\n" +
        "    <resource-env-ref-type>\n" +
        "            javax.enterprise.inject.spi.BeanManager\n" +
        "    </resource-env-ref-type>\n" +
        "  </resource-env-ref>\n" +
        "</web-app>";

    archive.addAsLibraries(WELD_SERVLET);
    archive.addAsManifestResource(new StringAsset(contextXml), "context.xml");
    archive.setWebXML(new StringAsset(webXml));
}
 
Example 2
public AutoDeployTestSupport(String testId) {

        File tmp = new File(System.getProperty("java.io.tmpdir"));
        tmpDir = new File(tmp, testId);
        cleanFile(tmpDir);
        tmpDir.mkdirs();
        tmpDir.deleteOnExit();

        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
        URL webxml = tccl.getResource("basic.war/web.xml");
        WebArchive war = ShrinkWrap.create(WebArchive.class, "basic.war");
        URL resource = tccl.getResource("basic.war/index.html");
        if (resource == null)
            throw new IllegalStateException("basic.war/index.html not found");
        war.addAsResource(resource, "index.html");
        war.setWebXML(webxml);

        basicWar = new File(tmpDir, "basic.war");
        basicWar.deleteOnExit();
        war.as(ZipExporter.class).exportTo(basicWar, true);
    }
 
Example 3
Source Project: trimou   File: IntegrationTestUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static WebArchive createTestArchiveBase() {
    WebArchive testArchive = ShrinkWrap.create(WebArchive.class);
    // Suppressing implicit bean archives without beans.xml
    testArchive.addAsManifestResource(CDI11_JBOSSALL_WORKAROUND_ASSET,
            "jboss-all.xml");
    // Add Weld servlet for embedded containers
    if (isServletContainer()) {
        testArchive.addAsLibraries(resolve("org.jboss.weld.servlet:weld-servlet"));
        testArchive.setWebXML(new StringAsset(Descriptors
                .create(WebAppDescriptor.class)
                .version(WebAppVersionType._3_0)
                .createListener()
                .listenerClass(
                        "org.jboss.weld.environment.servlet.Listener").up()
                .exportAsString()));
    }
    return testArchive;
}
 
Example 4
@Override
public void process(TestDeployment testDeployment, Archive<?> archive) {
    WebArchive war = (WebArchive) archive;

    String[] deps = {
            "io.smallrye:smallrye-config",
            "io.smallrye:smallrye-metrics",
            "io.smallrye:smallrye-metrics-testsuite-common",
            "org.eclipse.microprofile.metrics:microprofile-metrics-api",
            "org.eclipse.microprofile.config:microprofile-config-api"
    };
    File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity().asFile();
    war.addAsLibraries(dependencies);

    war.addClass(MetricsHttpServlet.class);
    war.addClass(JaxRsMetricsFilter.class);
    war.addClass(JaxRsMetricsServletFilter.class);

    // change application context root to '/' because the TCK assumes that the metrics
    // will be available at '/metrics', and in our case the metrics servlet is located
    // within the application itself, we don't use WildFly's built-in support for metrics
    war.addAsWebInfResource("WEB-INF/jboss-web.xml", "jboss-web.xml");

    // activate the servlet filter
    war.setWebXML("WEB-INF/web.xml");

    // activate the JAX-RS request filter
    war.addAsServiceProvider(Providers.class.getName(), JaxRsMetricsFilter.class.getName());

    // exclude built-in Metrics and Config from WildFly
    war.addAsManifestResource("META-INF/jboss-deployment-structure.xml", "jboss-deployment-structure.xml");
}
 
Example 5
Source Project: thorntail   File: DeploymentProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void process(Archive<?> archive, TestClass testClass) {
  JavaArchive extensionsJar = ShrinkWrap.create(JavaArchive.class,"mp-ot-mocktracer-resolver.jar")
               .addAsServiceProvider(TracerResolver.class, MockTracerResolver.class);
  extensionsJar.addAsServiceProvider(Providers.class, ExceptionMapper.class);
  extensionsJar.addClass(MockTracerResolver.class);
  extensionsJar.addClass(ExceptionMapper.class);
  extensionsJar.addPackages(true, "io.opentracing.tracerresolver", "io.opentracing.mock");

  WebArchive war = WebArchive.class.cast(archive);
  war.addAsLibraries(extensionsJar);
  war.setWebXML("web.xml");
}
 
Example 6
@Override
protected void handleWebArchive(WebArchive war) {
    Node node = war.get(WEB_XML_PATH);
    if (node == null) {
        throw new IllegalStateException("No web.xml in .war: " + war.toString(true));
    }

    war.addClass(GetLoginUrlServlet.class);

    WebAppDescriptor webXml = Descriptors.importAs(WebAppDescriptor.class).fromStream(node.getAsset().openStream());
    war.delete(WEB_XML_PATH); // delete first, so we can re-add
    webXml.servlet(UserLogin.USER_LOGIN_SERVLET_PATH + "-servlet", GetLoginUrlServlet.class.getName(), new String[]{"/" + UserLogin.USER_LOGIN_SERVLET_PATH});
    war.setWebXML(new StringAsset(webXml.exportAsString()));
}
 
Example 7
public static WebArchive buildArchive(String clazz) {
    WebArchive war = createWar();
    addClasses(war, clazz, AppEngineDataNucleusTransformer.class.getClassLoader());

    war.addPackage("com.google.appengine.datanucleus");

    war.addClass("com.google.appengine.datanucleus.jpa.JPATestCase$EntityManagerFactoryName");
    war.addClass("com.google.appengine.datanucleus.jdo.JDOTestCase$PersistenceManagerFactoryName");

    war.addPackage("com.google.appengine.datanucleus.query");

    war.addPackage("com.google.appengine.datanucleus.test.jdo");
    war.addPackage("com.google.appengine.datanucleus.test.jpa");

    war.setWebXML(new org.jboss.shrinkwrap.api.asset.StringAsset("<web/>"));
    war.addAsWebInfResource("appengine-web.xml");
    war.addAsWebInfResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
    war.addAsWebInfResource("META-INF/jdoconfig.xml", "classes/META-INF/jdoconfig.xml");
    war.addAsResource(new StringAsset("ignore.logging=true\n"), "capedwarf-compatibility.properties");

    final PomEquippedResolveStage resolver = getResolver("pom.xml");
    // GAE DN libs
    war.addAsLibraries(resolve(resolver, "com.google.appengine.orm:datanucleus-appengine"));
    war.addAsLibraries(resolve(resolver, "com.google.appengine:appengine-api-1.0-sdk"));
    war.addAsLibraries(resolve(resolver, "com.google.appengine:appengine-testing"));
    war.addAsLibraries(resolve(resolver, "com.google.appengine:appengine-api-stubs"));
    war.addAsLibraries(resolve(resolver, "org.datanucleus:datanucleus-core"));
    war.addAsLibraries(resolve(resolver, "org.datanucleus:datanucleus-api-jdo"));
    war.addAsLibraries(resolve(resolver, "org.datanucleus:datanucleus-api-jpa"));
    war.addAsLibraries(resolve(resolver, "javax.jdo:jdo-api"));
    war.addAsLibraries(resolve(resolver, "org.apache.geronimo.specs:geronimo-jpa_2.0_spec"));
    war.addAsLibraries(resolve(resolver, "org.easymock:easymock"));
    war.addAsLibraries(resolve(resolver, "org.easymock:easymockclassextension"));
    // TCK Internals
    war.addAsLibraries(resolve(resolver, "com.google.appengine.tck:appengine-tck-transformers")); // cleanup dep
    war.addAsLibraries(resolve(resolver, "com.google.appengine.tck:appengine-tck-base")); // lifecycle dep

    return war;
}
 
Example 8
@Deployment(testable = false)
public static WebArchive createDeployment() {
    final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
    webAppDescriptor.version("3.0");

    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
    webArchive.addPackage("org.superbiz.connector.api");
    webArchive.addPackage("org.superbiz.connector.adapter");
    webArchive.addPackage("org.superbiz.application");
    webArchive.addAsWebInfResource(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/resources.xml"), "resources.xml");
    webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
    System.out.println("Webapp:\n" + webArchive.toString(true));

    return webArchive;
}
 
Example 9
@Override
public void process(Archive<?> appArchive, TestClass testClass) {
    if (!(appArchive instanceof WebArchive)) {
        return;
    }
    log.info("Preparing archive: " + appArchive);
    // Only augment archives with a node indicating a MP-JWT test
    WebArchive war = WebArchive.class.cast(appArchive);
    Node configProps = war.get("/META-INF/microprofile-config.properties");
    Node publicKeyNode = war.get("/WEB-INF/classes/publicKey.pem");
    Node publicKey4kNode = war.get("/WEB-INF/classes/publicKey4k.pem");
    Node mpJWT = war.get("MP-JWT");
    if (configProps == null && publicKeyNode == null && publicKey4kNode == null && mpJWT == null) {
        return;
    }

    if (configProps != null) {
        StringWriter sw = new StringWriter();
        InputStream is = configProps.getAsset().openStream();
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
            String line = reader.readLine();
            while(line != null) {
                sw.write(line);
                sw.write('\n');
                line = reader.readLine();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        log.info("mp-config.props: "+sw.toString());
    } else {
        log.info("NO mp-config.props, adding /META-INF/MP-JWT-SIGNER");
        if(publicKey4kNode != null) {
            war.addAsManifestResource(publicKey4kNode.getAsset(), "MP-JWT-SIGNER");
        } else if(publicKeyNode != null) {
            war.addAsManifestResource(publicKeyNode.getAsset(), "MP-JWT-SIGNER");
        }
    }
    // This allows for test specific web.xml files. Generally this should not be needed.
    String warName = war.getName();
    String webXmlName = "/WEB-INF/" + warName + ".xml";
    URL webXml = WFSwarmWarArchiveProcessor.class.getResource(webXmlName);
    if (webXml != null) {
        war.setWebXML(webXml);
    }
    //
    String projectDefaults = "project-defaults.yml";
    war.addAsResource(projectDefaults, "/project-defaults.yml")
            .addAsWebInfResource("jwt-roles.properties", "classes/jwt-roles.properties")
    ;
    log.info("Augmented war: \n"+war.toString(true));
}
 
Example 10
Source Project: zstack   File: WarBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public void build() {
    WebArchive war = ShrinkWrap.create(WebArchive.class, "zstack.war");
    war.setWebXML(new File("src/test/resources/webapp/WEB-INF/web.xml"));
    war.addAsWebInfResource(new File("src/test/resources/webapp/WEB-INF/zstack-servlet-context.xml"), "classes/zstack-servlet-context.xml");
    new ZipExporterImpl(war).exportTo(new File(Utils.getPathUtil().join(warExportedToPath, war.getName())), true);
}
 
Example 11
Source Project: appengine-tck   File: TestBase.java    License: Apache License 2.0 4 votes vote down vote up
protected static WebArchive getTckDeployment(TestContext context) {
    enhanceTestContext(context);

    final WebArchive war;

    String archiveName = context.getArchiveName();
    if (archiveName != null) {
        if (archiveName.endsWith(".war") == false) archiveName += ".war";
        war = ShrinkWrap.create(WebArchive.class, archiveName);
    } else {
        war = ShrinkWrap.create(WebArchive.class);
    }

    // this package
    war.addPackage(TestBase.class.getPackage());
    // categories
    war.addPackage(IgnoreMultisuite.class.getPackage());
    // events
    war.addPackage(TestLifecycles.class.getPackage());
    // temp data
    war.addPackage(TempData.class.getPackage());
    // mail
    war.addPackage(EmailAddressFormatter.class.getPackage());
    // env
    war.addClass(Environment.class);

    // web.xml
    if (context.getWebXmlFile() != null) {
        war.setWebXML(context.getWebXmlFile());
    } else {
        war.setWebXML(new StringAsset(context.getWebXmlContent()));
    }

    // context-root
    if (context.getContextRoot() != null) {
        war.addAsWebInfResource(context.getContextRoot().getDescriptor());
    }

    // appengine-web.xml
    String appengineWebXmlFile = "appengine-web.xml";
    if (context.getAppEngineWebXmlFile() != null) {
        appengineWebXmlFile = context.getAppEngineWebXmlFile();
    }
    Asset gaeWebXml = new ClassLoaderAsset(appengineWebXmlFile);
    war.addAsWebInfResource(rewriteAsset(gaeWebXml), "appengine-web.xml");

    if (context.hasCallbacks()) {
        war.addAsWebInfResource("META-INF/datastorecallbacks.xml", "classes/META-INF/datastorecallbacks.xml");
    }

    if (context.getCompatibilityProperties() != null && (context.getProperties().isEmpty() == false || context.isUseSystemProperties())) {
        Properties properties = new Properties();

        if (context.isUseSystemProperties()) {
            properties.putAll(System.getProperties());
        }
        properties.putAll(context.getProperties());

        final StringWriter writer = new StringWriter();
        try {
            properties.store(writer, "GAE TCK testing!");
        } catch (IOException e) {
            throw new RuntimeException("Cannot write compatibility properties.", e);
        }

        final StringAsset asset = new StringAsset(writer.toString());
        war.addAsWebInfResource(asset, "classes/" + context.getCompatibilityProperties());
    }

    if (context.isIgnoreTimestamp() == false) {
        war.addAsWebInfResource(new StringAsset(String.valueOf(context.getTimestamp())), "classes/" + TIMESTAMP_TXT);
    }

    return war;
}
 
Example 12
Source Project: tomee   File: EARTest.java    License: Apache License 2.0 4 votes vote down vote up
@Deployment
public static EnterpriseArchive createDeployment() {

    final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar");
    apiJar.addPackage("org.superbiz.connector.api");
    System.out.println("API JAR:\n" + apiJar.toString(true));

    final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar");
    implJar.addPackage("org.superbiz.connector.adapter");
    System.out.println("IMPL JAR:\n" + implJar.toString(true));

    final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar");
    rar.addAsLibraries(implJar);

    final File raXml = Basedir.basedir("../connector-sample-rar/src/main/rar/META-INF/ra.xml");
    rar.setResourceAdapterXML(raXml);
    System.out.println("RAR:\n" + rar.toString(true));

    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
    webArchive.addPackage("org.superbiz.application");

    final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
    webAppDescriptor.version("3.0");

    final File resourcesXml = Basedir.basedir("../connector-sample-war/src/main/webapp/WEB-INF/resources.xml");
    webArchive.addAsWebInfResource(resourcesXml);
    webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
    webArchive.addAsWebInfResource(resourcesXml);
    webArchive.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
    System.out.println("Webapp:\n" + webArchive.toString(true));

    final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear");
    enterpriseArchive.addAsLibraries(apiJar);
    enterpriseArchive.addAsModule(rar);
    enterpriseArchive.addAsModule(webArchive);

    ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class);
    applicationXml.displayName("connector-sample-ear");
    applicationXml.createModule()
            .getOrCreateWeb()
                .webUri("connector-sample-war.war")
                .contextRoot("/sample")
            .up().up()
            .createModule().connector("connector-sample-ra.rar")
            .up().libraryDirectory("lib");

    enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString()));
    System.out.println(enterpriseArchive.toString(true));

    return enterpriseArchive;
}
 
Example 13
public static EnterpriseArchive createDeployment() {

        final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar");
        apiJar.addPackage("org.superbiz.connector.api");
        System.out.println("API JAR:\n" + apiJar.toString(true));

        final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar");
        implJar.addPackage("org.superbiz.connector.adapter");
        System.out.println("IMPL JAR:\n" + implJar.toString(true));

        final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar");
        rar.addAsLibraries(implJar);

        final File raXml = Basedir.basedir("../connector-sample-rar/src/main/rar/META-INF/ra.xml");
        rar.setResourceAdapterXML(raXml);
        System.out.println("RAR:\n" + rar.toString(true));

        final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
        webArchive.addPackage("org.superbiz.application");

        final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
        webAppDescriptor.version("3.0");

        final File resourcesXml = Basedir.basedir("../connector-sample-war/src/main/webapp/WEB-INF/resources.xml");
        webArchive.addAsWebInfResource(resourcesXml);
        webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
        webArchive.addAsWebInfResource(resourcesXml);
        webArchive.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
        System.out.println("Webapp:\n" + webArchive.toString(true));

        final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear");
        enterpriseArchive.addAsLibraries(apiJar);
        enterpriseArchive.addAsModule(rar);
        enterpriseArchive.addAsModule(webArchive);

        ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class);
        applicationXml.displayName("connector-sample-ear");
        applicationXml.createModule()
                .getOrCreateWeb()
                .webUri("connector-sample-war.war")
                .contextRoot("/sample")
                .up().up()
                .createModule().connector("connector-sample-ra.rar")
                .up().libraryDirectory("lib");

        enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString()));
        System.out.println(enterpriseArchive.toString(true));

        return enterpriseArchive;
    }
 
Example 14
@Deployment
public static EnterpriseArchive createDeployment() {

    final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar");
    apiJar.addPackage("org.superbiz.connector.api");
    System.out.println("API JAR:\n" + apiJar.toString(true));

    final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar");
    implJar.addPackage("org.superbiz.connector.adapter");
    System.out.println("IMPL JAR:\n" + implJar.toString(true));

    final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar");
    rar.addAsLibraries(implJar);

    rar.setResourceAdapterXML(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/ra.xml"));
    System.out.println("RAR:\n" + rar.toString(true));

    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
    webArchive.addPackage("org.superbiz.application");

    final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
    webAppDescriptor.version("3.0");

    webArchive.addAsWebInfResource(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/resources.xml"), "resources.xml");
    webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
    System.out.println("Webapp:\n" + webArchive.toString(true));

    final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear");
    enterpriseArchive.addAsLibraries(apiJar);
    enterpriseArchive.addAsModule(rar);
    enterpriseArchive.addAsModule(webArchive);

    ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class);
    applicationXml.displayName("connector-sample-ear");
    applicationXml.createModule()
            .getOrCreateWeb()
                .webUri("connector-sample-war.war")
                .contextRoot("/sample")
            .up().up()
            .createModule().connector("connector-sample-ra.rar")
            .up().libraryDirectory("lib");

    enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString()));
    System.out.println(enterpriseArchive.toString(true));

    return enterpriseArchive;
}
 
Example 15
public void start() {
  Properties serverProperties = readProperties();
  int port = Integer.parseInt(serverProperties.getProperty(PORT_PROPERTY));

  tomcat = new Tomcat();
  tomcat.setPort(port);
  tomcat.setBaseDir(getWorkingDir());

  tomcat.getHost().setAppBase(getWorkingDir());
  tomcat.getHost().setAutoDeploy(true);
  tomcat.getHost().setDeployOnStartup(true);

  String contextPath = "/" + getContextPath();

  // 1) Must not use shrinkwrap offline mode (see longer explanation at the end of the file)
  // 2) Must use configuration via Shrinkwrap Maven plugin (see pom.xml for plugin definition);
  //    This forwards things like the location of the settings.xml file to Shrinkwrap. We need
  //    that for our CI where settings.xml is not in the default location.
  PomEquippedResolveStage resolver = Maven.configureResolver()
    .useLegacyLocalRepo(true).configureViaPlugin();

  WebArchive wa = ShrinkWrap.create(WebArchive.class, "rest-test.war").setWebXML(webXmlPath)
      .addAsLibraries(resolver.resolve("org.codehaus.jackson:jackson-jaxrs:1.6.5").withTransitivity().asFile())
      .addAsLibraries(resolver.addDependencies(
          MavenDependencies.createDependency("org.mockito:mockito-core", ScopeType.TEST, false,
          MavenDependencies.createExclusion("org.hamcrest:hamcrest-core"))).resolve()
            .withTransitivity().asFile())

      .addAsServiceProvider(ProcessEngineProvider.class, MockedProcessEngineProvider.class)
      .add(new ClassLoaderAsset("runtime/tomcat/context.xml"), "META-INF/context.xml")
      .addPackages(true, "org.camunda.bpm.engine.rest");

  addRuntimeSpecificLibraries(wa, resolver);
  wa.setWebXML(webXmlPath);

  String webAppPath = getWorkingDir() + "/" + getContextPath() + ".war";

  wa.as(ZipExporter.class).exportTo(new File(webAppPath), true);

  tomcat.addWebapp(tomcat.getHost(), contextPath, webAppPath);

  try {
    tomcat.start();
  } catch (LifecycleException e) {
    throw new RuntimeException(e);
  }
}