Packaging

From
Jump to navigation Jump to search

Overview


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.

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 home, component, and/or web service endpoint 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, component, and/or web service endpoint interfaces depend on, except J2EE 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.

Example


In this example, the Bean Provider has chosen to package the enterprise bean client view classes in a separate jar file and to reference that jar file from the other jar files that need those classes. Those classes are needed both by ejb2.jar, packaged in the same application as ejb1.jar, and by ejb3.jar, packaged in a different application. Those classes are also needed by ejb1.jar itself because they define the remote interface of the enterprise beans in ejb1.jar, and the Bean Provider has chosen the by reference approach to making these classes available.

The deployment descriptor for ejb1.jar names the client view jar file in the ejb-client-jar element. Because ejb2.jar requires these client view classes, it includes a Class-Path reference to ejb1_client.jar.

The Class-Path mechanism must be used by components in app2.ear to reference the client view jar file that corresponds to the enterprise beans packaged in ejb1.jar of app1.ear. Those enterprise beans are referenced by enterprise beans in ejb3.jar. Note that the client view jar file must be included directly in the app2.ear file.

app1.ear:

   META-INF/application.xml
   ejb1.jar     Class-Path: ejb1_client.jar
        deployment descriptor contains:
             <ejb-client-jar>ejb1_client.jar</ejb-client-jar>
   ejb1_client.jar
   ejb2.jar      Class-Path: ejb1_client.jar


app2.ear:

   META-INF/application.xml
   ejb1_client.jar
   ejb3.jar     Class-Path: ejb1_client.jar