The ejb-jar file is the standard format for the packaging of enterprise beans. The ejb-jar file format is used to package un-assembled enterprise beans (the Bean Provider's output), and to package assembled applications (the Application Assembler's output).
The ejb-jar file format is the contract between the Bean Provider and the Application Assembler, and between the Application Assembler and the Deployer.
An ejb-jar file produced by the Bean Provider contains one or more enterprise beans that typically do not contain application assembly instructions. The ejb-jar file produced by an Application Assembler (which can be the same person or organization as the Bean Provider) contains one or more enterprise beans, plus application assembly information describing how the enterprise beans are combined into a single application deployment unit.
The ejb-jar file must contain the deployment descriptor (if any) in the format defined in the Deployment Descriptor XML Schema. The deployment descriptor must be stored with the name META-INF/ejb-jar.xml in the ejb-jar file.
NOTE: The biggest difference with EJB 2.0 is that with the EJB 3.0 release the deployment descriptor becomes optional.
ejb-jar File Requirements
The ejb-jar file must contain, either by inclusion or by reference, the class files of each enterprise bean as follows:
The enterprise bean class.
The enterprise bean business interfaces, web service endpoint interfaces, and home and component interfaces.
The primary key class if the bean is an entity bean.
We say that a jar file contains a second file "by reference" if the second file is named in the Class-Path attribute in the Manifest file of the referencing jar file or is contained (either by inclusion or by reference) in another jar file that is named in the Class-Path attribute in the Manifest file of the referencing jar file.
The ejb-jar file must also contain, either by inclusion or by reference, the class files for all the classes and interfaces that each enterprise bean class and the home interfaces, component interfaces, and/or web service endpoints depend on, except Java EE and J2SE classes. This includes their superclasses and superinterfaces, dependent classes, and the classes and interfaces used as method parameters, results, and exceptions.
The Application Assembler must not package the stubs of the EJBHome and EJBObject interfaces in the ejb-jar file. This includes the stubs for the enterprise beans whose implementations are provided in the ejb-jar file as well as the referenced enterprise beans. Generating the stubs is the responsibility of the container. The stubs are typically generated by the Container Provider's deployment tools for each class that extends the EJBHome or EJBObject interfaces, or they may be generated by the container at runtime.