Create EJB modules

An enterprise bean is a Java component that can be combined with other resources to create J2EE applications.

 

Before you begin

This article assumes that you have created and unit tested an enterprise bean (EJB file) that you want to assemble in an enterprise application and deploy onto an application server.

 

Overview

In an Application Server Toolkit (AST) or Rational Web Developer assembly tool, one can create and test enterprise beans that conform to the distributed component architecture defined in the Sun Microsystems EJB specification and that support extended functionality for WebSphere Application Server.

We can create enterprise beans (either with or without inheritance) such as session beans, container-managed persistence (CMP) entity beans, bean-managed persistence (BMP) entity beans, or message-driven beans. Using the EJB deployment descriptor editor of an assembly tool, one can set deployment descriptor and assembly properties for enterprise beans.

This article describes how to create an EJB project (or EJB module) using an assembly tool.

 

Procedure

  1. Start an assembly tool.

  2. If you have not done so already, configure the assembly tool for work on J2EE modules. Ensure that the J2EE capability is enabled.

  3. Click...

    File | New | Project | EJB | EJB Project | Next

    ...Or, if you have created a J2EE project before, click...

    File | New | EJB Project

  4. In the New EJB Project dialog:

    1. Name the EJB project and specify its location. To change the default project location, click Browse and specify a new location. If you specify a non-default project location that is already being used by another project, one cannot create the project.

    2. Select the EJB specification version to which you want your EJB project to adhere. If you plan on using EJB 2.1 enterprise beans, specify an EJB 2.1 project. We can add EJB 1.1 enterprise beans to an EJB 2.1 project. An EJB 2.1 project must exist in a J2EE 1.4 enterprise application project. An EJB 2.0 project can exist in a J2EE 1.4 or 1.3 enterprise application project. Your available options can differ, depending on the J2EE preferences defined.

    3. Select a target server. Select the WAS v6.0 target server to use V6 WebSphere Application Server capabilities.

    4. If you want to add EJB components to an enterprise application (EAR file), select Add module to an EAR project.

    5. Specify a new or existing enterprise application (EAR) project to be associated with your new EJB project for purposes of deployment. Select an existing enterprise application project from the drop-down list or type a new project name. Or, click New and create a new enterprise application. Note that if you type a new EAR project name, the EAR project is created in the default location with the lowest compatible J2EE version based on the version of the project being created. If you want to specify a different version or a different location for the enterprise application, click New and create a new enterprise application.

    6. Specify whether you want to add support for annotated Java classes to the EJB module.

    7. Specify whether you want to create a default stateless session bean.

    8. Optional: If you are creating a new enterprise application project or if you have no module dependencies to specify, skip this step. Otherwise, click Next to create an EJB client JAR file from your existing enterprise bean. On the EJB Client JAR Creation page, specify a URI, name and project location for the EJB client JAR file. If you have no module dependencies to specify, skip the rest of this step; otherwise, click Next. On the Module Dependencies page, select dependent JAR files or modules within the associated enterprise application project. This updates the runtime class-path and Java project build path with the appropriate JAR files. Application client modules, EJB modules, and Web modules can all have dependencies on EJB modules or utility JAR files. Modules cannot depend on WAR or application client JAR files.

    9. Click Finish to create the EJB project.

 

Result

A new EJB project is created, reflecting the J2EE folder structure that specifies the location of enterprise bean content files, class files, class paths, the deployment descriptor, and supporting metadata. Files for the EJB project are shown in the Project Explorer view under Enterprise Applications and EJB Projects.

 

What to do next

After you have an EJB project to hold enterprise beans, one can do the following:

For detailed instructions on creating CMP fields or CMP finder methods for entity beans, relating CMP fields, adding methods to interfaces, or managing enterprise beans, refer to articles under EJB assembly in the Application Server Toolkit information center that accompanies this information center.


 

See Also


EJB modules
Enterprise (J2EE) applications

 

Related Tasks


Assembling EJB modules
Assembling applications
Creating enterprise applications

 

Related Information


Import EJB files