Deploy WAR or "fat" JAR?

AdjustingForInflation picture AdjustingForInflation · Apr 15, 2014 · Viewed 8k times · Source

I'm noticing a lot of projects (DropWizard, Grails, etc.) starting to embrace the notion of a "fat" JAR (using an embedded web server like Jetty or Tomcat) vs. the traditional WAR deploy. Both methods involve a single JVM process (i.e. no matter how many WARs are deployed to Tomcat, it's all the same JVM process).

Under what circumstances is either deployment method preferable over the other?

Answer

wavicle picture wavicle · Apr 15, 2014

Here are some reasons:

In favor of JAR:

  1. Simple to build and deploy.
  2. Embedded servers like Jetty are easy to operate.
  3. Applications are easy for users to start and they can run on their personal computers too, because they are lightweight.
  4. Starting and stopping applications will require less knowledge than managing web servers.

In favor of WAR or EAR:

  1. The server would provide features like deployment, restart, security and so on for multiple web applications simultaneously.
  2. Perhaps a separate deployment team can handle the starting and stopping of apps.
  3. If your supervisors like to follow rules, they will be happy to find that you are not breaking them.

Having said this, you can always provide 2 or 3 types of executables to cater to all needs. Any build tool makes this easy.