• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Why ear and war files?

 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,
I know it is easier to deploy one *.ear file which contains one or more *.jar and *.war files instead of deplying them in a exploded directories. Is there any other reason to use an ear file for an application? Thanks.
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ears make packaging and deployment of J2EE Applications easier (especially those using both EJB and Servlets/JSP).
If you are only doing Servlets/JSP then it may not make much of a difference. The real benefit is when you are using EJBs along with Servlets/JSP and possibly even connectors. In this case you can package all of your J2EE Components in one file instead of individually deploying numerous components separately and then dealing with the classloading issues among these components and other configuration settings.
For example, in WebLogic all war components have access to the ejb classes in the ear (because the war classloader is a child of the ejb classloader). Therefore, there is no need to package ejb-client jars in the war. Managing these classloading dependencies would be a pain if the wars were deployed separately.
Beyond this, packaging as an ear allows components to explicitly define dependencies to other components within the ear using the Extension Mechanism Architecture. This makes sharing classes between the ejb tier and web tier possible without duplicating classes in multiple stops or resorting to putting classes on the classpath.
All of this hopefully allows us to develop and package a complete J2EE application in a vendor neutral manner, without the need of tens of pages of deployment documentation. Just drop in the ear and go.
Of course, the reality of the situation is that it is still very hard to achieve this. Classloading differenences in Application Servers make this nearly impossible. That however, doesn't mean we still shouldn't try.
Let me reiterate, for your specific situation packaging as an ear may not buy you much. However, there are situations where it is very beneficial.
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chris,
I am missing something here. I think it is an usual practice during development phase to use jar files for EJB components and edit the Manifest file to add the dependent jar files. If you think of any other way of deploying EJBs during development env please let me know.
Having gone through the process of eliminating the class loader issues during development, can you tell me any other reasons to deploy using ear files?
I understand that it is easy to ftp one ear file instead of many files. But that reason alone doesn't convince me to use ear files.
Thanks.
 
Chris Mathews
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
War and Ear are packaging model. It doesn't matter if you use them in a jar or as an exploded directory, the model is still the same. You are still deploying ears and wars.
Are you asking why jar it instead of using an exploding format? In that case then the answer is convenience. It is more convenient to deal with a single file then a large number of files.
However, the benefit is tightly tied to your situation. If you see no benefit to actually jarring your ear... don't. The important part is the structure.
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic