Question

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...

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top