Embedded vs Non-Embedded Java Server

Traditionally, to host Java web applications, you installed a single Tomcat instance on your server, and pushed all of your WAR files onto that one server. Maybe you clustered a few Tomcat instances together, but the idea is the same. There was one Tomcat server, and all of your Java web apps were deployed to it.

Traditional vs Embedded Tomcat

In the world of microservices, things are a little different. Instead of one Tomcat server hosting many web applications, with microservices, we take the one web application, deploy that one web application to a one tomcat server, and then zip it all up in a zip, jar or war file that is executable through the Java command. So now we have a single executable file that contains everything you need to run the web app, including the Tomcat server.

Container Based Distribution

Some products ship their entire product in an embedded servlet engine. You can get Jenkins in a single executable WAR file, although I believe they embed Jetty, not Tomcat, but it's the same idea. But less likely than distributing the jar/war, what people do is package the whole thing up in a docker container and deploy it all to Kubernetes or Heruku or whatever.

So that's kinda the idea behind an embedded tomcat server.

Maven and Embedded Tomcat

One of the easiest way to create an embedded tomcat server is with Apache Maven. Here's an example of a Maven build that not only builds a web app, but also downloads tomcat and packages the whole thing in an executable JAR:

Embedded Tomcat with Maven


From here, it's when you "embed" tomcat into your application. That is, you are responsible for starting and stopping tomcat. This is the reverse of a normal container operation, but you might find it useful for rapid deployment and testing.


"Embedded" means that you program ships with the server within it as opposed to a web application being deployed to external server.

With embedded server your application is packaged with the server of choice and responsible for server start-up and management.

From the user standpoint the difference is:

  • Application with embedded server looks like a regular java program. You just launch it and that's it.
  • Regular web application is usually a war archive which needs to be deployed to some server

Embedding a server is very useful for testing purposes where you can start or stop server at will during the test.