Home arrow Java & J2EE arrow Page 7 - Introduction to Enterprise JavaBeans

The EJB-JAR File - Java

This chapter looks at one of the principal types of component in the Java 2 Platform, Enterprise Edition (J2EE) Enterprise JavaBeans (EJBs). See how EJBs are applied and how they are deployed. (This is chapter 4 from Sams Publishers, author Martin Bond, et. al., Teach Yourself J2EE in 21 Days, second edition, ISBN: 0-672-32558-6).

  1. Introduction to Enterprise JavaBeans
  2. Types of EJB and Common Uses of EJBs
  3. What's in an EJB?
  4. The Home Interface
  5. Implementing the Home Interface
  6. Verifying an EJB
  7. The EJB-JAR File
  8. How Do I Deploy an EJB?
  9. Disposing of the EJB
  10. Using the J2EE Reference Implementation
  11. Examining the Case Study Application
  12. Verifying the Case Study Application
  13. Managing J2EE RI Applications
  14. Troubleshooting the Case Study Application
By: Martin Bond
Rating: starstarstarstarstar / 41
June 21, 2004

print this article



All of the EJB classes and the deployment descriptor should be bundled up in a JAR file. The deployment descriptor is stored in a META-INF directory (the same location as the JAR manifest file) and must be named ejb-jar.xml. If there are multiple EJBs packaged in the same JAR file, the deployment descriptor will have multiple EJB definitions in it. The JAR file is then termed an EJB-JAR file to denote its payload. The JAR file itself can be called anything (but obviously a name appropriate to the application makes most sense) and conventionally has a .jar file extension.

The EJB-JAR file can also contain any extra resources required by the EJB, such as platform-specific configuration information that does not fit in the standard deployment descriptor.

Typical contents of a platform specific deployment descriptor are

  • The JNDI name the EJB must be deployed under Mappings between resources referenced in the J2EE components such as EJBs and the actual resources within the J2EE server

An EJB-JAR file can store more than one platform-specific deployment descriptor file, enabling it to be used with different J2EE implementations. Although the EJB-JAR file is now complete, it must form part of an application to serve a useful purpose. J2EE defines that enterprise applications can be built from components (Web, EJB, and Client Application components). Therefore, a second JAR file is used to bundle these J2EE components into a complete J2EE Application, this is called the Enterprise Archive file.

The Enterprise Archive File

The Enterprise Archive (EAR) file contains a number of J2EE components comprising an application and yet another deployment descriptor. This descriptor includes a description of the application, which components it uses, how those components relate to each other, and which specific resources they use. This is the information provided by the Application Assembler and Deployer.

The application deployment descriptor is also an XML document, called application.xml, and it is stored in the META-INF directory of the Enterprise Archive (which although a JAR file the Enterprise Archive typically has a filename extension of .ear not .jar). Listing 4.6 shows the application.xml descriptor for the Agency application.

Listing 4.6 Agency Bean EJB Deployment Descriptor

<?xml version="1.0" encoding="UTF-8"?>
<application version="1.4" xmlns="
 <description>Application description</description>

The application.xml file just lists the modules that form the enterprise application, in this case the single Agency EJB contained in agency-session-ejb.jar.

An EAR file may also contain one or more platform-specific deployment descriptors for the application enabling it to be used with different J2EE implementations.

This chapter is from Teach Yourself J2EE in 21 Days, second edition, by Martin Bond et. al. (Sams, 2004, ISBN: 0-672-32558-6). Check it out at your favorite bookstore today. Buy this book now.

>>> More Java & J2EE Articles          >>> More By Martin Bond

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates


Dev Shed Tutorial Topics: