Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WAR vs EAR for web application with no EJB?

I have a Java EE web application that does not make use of EJBs. I am targeting Jetty/Tomcat for deployment some of the time and thus need a WAR packaging. However, I am also target JBoss and Websphere some of the time.

My understanding is that full-blown Java EE application servers can take either EAR or WAR formats. When would I use one over the other and why? I understand they are both standard compressed file formats and I have read 10 different snippets that try to explain them (including this one), but am no closer to understanding the pros and cons of each.

like image 806
HDave Avatar asked Sep 27 '10 15:09

HDave


People also ask

What is difference between WAR and EAR?

An EAR file requires a fully Java Platform, Enterprise Edition (Java EE)- or Jakarta Enterprise Edition (EE)-compliant application server, such as WebSphere or JBoss, to run. A WAR file only requires a Java EE Web Profile-compliant application server to run, and a JAR file only requires a Java installation.

Does Tomcat support EAR file?

ear. A WAR file is a specialized JAR file containing Web application components such as servlets, JSP files, HTML files, deployment descriptors, utility JAR files, etc. A WAR file can be deployed to a Web server such as Tomcat.

What are WAR files used for?

In software engineering, a WAR file (Web Application Resource or Web application ARchive) is a file used to distribute a collection of JAR-files, JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static web pages (HTML and related files) and other resources that together constitute a web ...

What is EJB and EAR?

EJB components are packaged into modules as jar files and are packaged into application enterprise archive as ear file. There are majorly three components of any enterprise application − jar − Java Application aRchive, containing EJB modules, EJB client modules and utility modules.


1 Answers

If you have only web modules - use WAR file. If you have different Java EE modules - use EAR. Though you can deliver only web modules in EAR - there is no point in doing this (and you will need to do more complex deployment configuration)

like image 134
Andriy Sholokh Avatar answered Oct 20 '22 04:10

Andriy Sholokh