8

Is there any easy way to deploy a servlets web application with undertow embbeded?

For example, with jetty, I can deploy like this:

    Server server = new Server(8080);
    WebAppContext context = new WebAppContext();
    context.setContextPath("/");
    context.setDescriptor("src/main/webapp/web.xml");
    context.setResourceBase("src/main/webapp/");
    server.setHandler(context);
    server.start();

Is there a similar way of doing this with undertow? I saw a example here: https://github.com/undertow-io/undertow/blob/master/examples/src/main/java/io/undertow/examples/servlet/ServletServer.java, but it's not exaclty what I want, it registers the servlets one by one...

Chico Sokol
  • 1,254
  • 3
  • 16
  • 24

2 Answers2

3

Not at the moment.

Undertow just provides a builder API, that another application can use to build up a Servlet. This was a deliberate design choice as it gives the embedding application full control of the deployment.

We may eventually add support for this in a different module (most likely by ripping the relevant code out of Wildfly), but it is not high on the priority list at the moment.

Stuart Douglas
  • 847
  • 5
  • 4
  • Thanks! Can you point me the code from wildfly that bootstrap a web application? I found this [class](https://github.com/wildfly/wildfly/blob/master/undertow/src/main/java/org/wildfly/extension/undertow/deployment/UndertowDeploymentProcessor.java) but I think that's not the right class or I simply could not understand it :D – Chico Sokol Mar 11 '14 at 17:04
  • You did found the right class. most of the work is happening in UndertowDeploymentProcessor and https://github.com/wildfly/wildfly/blob/master/undertow/src/main/java/org/wildfly/extension/undertow/deployment/UndertowDeploymentInfoService.java Also you should take into account that descriptor(web.xml & friends) parsing is done by jboss metadata project https://github.com/jboss/metadata – Tomaz Cerar Apr 10 '14 at 22:48
  • 1
    Any update on supporting standard war file deployment i.e., as a replacement for Tomcat (just Tomcat features)? – manikanta Jan 03 '15 at 05:43
2

I think the new wildfly swarm project provides a good workaround for that as you can deploy any webapp just with the undertow module picked from wildfly and packaged in a single fat jar. A good example is here: https://github.com/wildfly-swarm/wildfly-swarm-examples/tree/master/servlet

Yumarx Polanco
  • 2,195
  • 1
  • 19
  • 33
Guillaume D.
  • 3,284
  • 3
  • 20
  • 26