Friday, 14 December 2012

Weblogic Server ear file directory structure


Weblogic Server : Directory Structure Of  ear ( Enterprise Applications ) File


In weblogic, Archived file with extension .ear also called enterprises application is a group of other java enterprises modules such as web applications ( .war archive ), EJB's ( .jar archive ) etc. it has it's own descriptor file called application.xml which contains information about the different kind of modules packaged or available inside that particular .ear file or you can say, it's a standard J2EE configuration file that specifies which modules are in the J2EE application. 

Apart from application.xml, one more weblogic descriptor file is there for ear file called weblogic-application.xml but optional if you are not using any WebLogic Server extensions. weblogic-application.xml file is the WebLogic Server-specific deployment descriptor extension for the application.xml Java EE deployment descriptor and this is where you configure features such as shared Java EE libraries referenced in the application and EJB caching.

Both weblogic-application.xml & application.xml located in the META-INF


So, an EAR file contains - 

1. META-INF ( containing application.xml,weblogic-application.xml & MANIFEST.MF )
2. APP-INF  ( containing folder "lib" and "classes", explained later )
3. Web Module ( war archive file )
4. EJB Module ( jar archive file )


See the diagram below 







1. META-INF ( containing application.xml,weblogic-application.xml & MANIFEST.MF )

The META-INF/ directory can contain the following files :

application.xml, as I have explained above, contains information about the different kind of modules packaged or available inside that particular .ear file or you can say, it's a standard J2EE configuration file that specifies which modules are in the J2EE application. 

 weblogic-application.xml file is the WebLogic Server-specific deployment descriptor extension for the application.xml Java EE deployment descriptor and this is where you configure features such as shared Java EE libraries referenced in the application and EJB caching. it's an optional file if you are not using any WebLogic Server extensions.

MANIFEST.MF is also an optional file that can be used to specify additional meta-information for the EAR.
( for more details visit http://docs.oracle.com/javase/1.4.2/docs/guide/jar/jar.html#JAR )

2. APP-INF  ( containing folder "lib" and "classes", explained later )

APP-INF folder is used to place the common modules used between all of your application archived in a particular ear file. For example, suppose you have archived two war files like myapp1.war and myapp2.war in a ear file called myentapp.ear, and there are few functionality common on both web archive file so instead of creating and archiving separate ejb's for both web app, you can archive common ejb's in a jar file like shared.jar and place that file inside APP-INF/lib folder.

 In the same way, if you have some common class files for both war files then you can place then inside APP-INF/classes.


3. Web Module ( war archive file )

See my this post - http://weblogicserveradministration.blogspot.com/2010/10/deployment-creating-war-file-and.html


4. EJB Module ( jar archive file )

EJB deployment descriptors are defined in ejb-jar,xml.
Weblogic related descriptors are defined in weblogic-ejb-jar.xml.
Further, class files are located under main jar folder.


How to create a EAR file 


To create an ear ( Enterprises Application ) - 

1. Create a temporary staging directory anywhere on your hard drive.

2. Copy the Web archives (WAR files) and EJB archives (JAR files) into the staging directory.

3. Create a META-INF subdirectory in the staging directory

4. Set up your shell environment by running setDomainEnv script inside domain/bin folder

5. Create the application.xml deployment descriptor file that describes the enterprise   
     application in the META-INF directory. 

6. Optionally create the weblogic-application.xml file manually in the META-INF directory if 
    needed.

7. Create the Enterprise Archive (EAR file) for the application, using a jar command such as:

     jar cvf application.ear -C your_staging_dir



Other My Related Posts


1. WAR File Directory Structure, Creating war file
2. WAR Files Overview
3. Packaging Weblogic Deployment Files
4. Create jar, war and ear Files
5. Difference Between jar, war and ear Files






No comments:

Post a Comment