5
votes

We're deploying our JavaEE 7 application on Wildfly 8. Previously, we've packaged all of our enterprise applications (WAR, multiple EJB JAR files) as an EAR. However, with JavaEE now allowing you to package EJBs in a WAR file (or as a JAR within the WAR's WEB-INF/lib) we're wondering if there is any benefit in deploying an EAR rather than going with WAR packaging.

Does an EAR provide something that a WAR does not? It certainly reduces packaging complexity to make use of a WAR. Is there any difference in terms of deployment? EJB naming? Anything?

2

2 Answers

5
votes
  • Easier to deploy (only one package instead of multiples).
  • Some server (example Weblogic, but not wildfly) allow shared session for an entire EAR.
  • In general, EAR provide more option to configure with AS.
  • Special folder (APP-INF) that let you define a config file application.xml.

If your application would consist only of multiple WARs then you may not find it such a big deal to maintain multiple deploy. However, consider an application which use WARs, EJBs, JMS etc. It will be a lot easier to mananage the interaction between all these components in an EAR.

You might want to read the packaging application part of the Java EE tutorial.

0
votes

Setup of deployment of an EAR is painfully hard work (especially under Weblogic). Deployment of a WAR is simpler. Deployment as EAR has two benefits:

  1. You can aggregate several unlinked applications in one file (whole eggs in one basket).
  2. You can reduce size of this file with help of skinny war technology.
  3. Your devops can deploy only one application instead of several. Links restoring is not needed.
  4. You can setup a well build barrier between in\out ear modules.

And many many others.

In other words one-war pattern in most of cases is devoted only for test and training purposes.