I need to deploy to a PaaS (HANA Cloud Platform) that only supports a Tomcat container and also want to run Vert.x as an async framework.
What I did so far is to bootstrap Vert.x through a servlet:
public class VertxServlet extends HttpServlet {
...
@Override
public void init(ServletConfig cfg) {
Vertx vertx = Vertx.vertx();
vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {
public void handle(HttpServerRequest req) {
System.out.println("Got request: " + req.uri());
System.out.println("Headers are: ");
for (Map.Entry<String, String> entry : req.headers()) {
System.out.println(entry.getKey() + ":" + entry.getValue());
}
req.response().headers().set("Content-Type", "text/html; charset=UTF-8");
req.response().end("<html><body><h1>Hello from vert.x!</h1></body></html>");
}
}).listen(8888);
}
...
}
And in my web.xml I put this:
<servlet>
<servlet-name>VertxServlet</servlet-name>
<display-name>VertxServlet</display-name>
<description></description>
<servlet-class>com.mypackage.VertxServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
It works quite well. The problem is that the PaaS is not able to configure the port mapping. The whole Tomcat including the reverse proxy is a prepared solution.
Questions:
Is it a viable approach to run Vert.x as a
.war
file or does it have any limitations and difficulties that may occur later?Is there a way of binding my little Vert.x server to the default Tomcat port without running into a port conflict?
Thank you