Home

 

Creating an EJB project

To develop the session EJB, we create an EJB project. It is also typical to create an enterprise application (EAR) project that is the container for deploying the EJB project.

Note: With EJB 3.0, we can also use a utility project to hold the EJB classes, but it is more flexible to use an EJB project.

To create a Java EE EJB project, do these steps:

Open the Java EE perspective.

In the Workbench, select File Æ New Æ Project.

In the New Project dialog, select EJB Æ EJB Project and click Next.

In the New EJB Project dialog (Figure | 4-8):

Enter RAD75EJB in the Name field.
For Target Runtime, select WebSphere Application Server v7.0.
For EJB Module version, select 3.0.
Select Add project to an EAR (default) and enter RAD75EJBEAR for EAR Project Name field. By default, the wizard creates a new EAR project, but you can also select an existing project from the drop-down combo box. If you would like to create a new project and also configure its location, click New. For our example, we use the given default value.
For Configuration, select Default Configuration for WebSphere Application Server v7.0. Optionally click Modify to see the project facets (EJB Module 3.0, Java 6.0, WebSphere EJB (Extended) 7.0).
Click Next.

Figure 14-8 Create an EJB project wizard (1)

In the EJB Module dialog (Figure | 4-9) enter the following items:

Source folder: ejbModule (default)
Clear Create an EJB Client JAR Project to hold client interfaces and classes (default).
Select Generate deployment descriptor.
Click Finish.

Figure 14-9 Create an EJB project wizard (3)

Note: The EJB client JAR holds the interfaces of the enterprise beans, and other classes that these interfaces depend on, such as their superclasses and implemented interfaces, the classes and interfaces used as method parameters, results, and exceptions.

The EJB client JAR can be deployed together with a client application that accesses the EJBs. This results in a smaller client application as compared to deploying the EJB project with the client application.

However, with EJB 3.0, EJBs are annotated Java classes that are lightweight compared to EJB 2.1 EJBs, so the need for a client JAR is minimal.

If the current perspective is not the Java EE perspective when you create the project RAD prompts you to switch to the Java EE perspective. Click Yes.

The Technology Quickstarts view opens. You can click a link to open the Application Developer Help with a matching tutorial. Close the view.

The Enterprise Explorer contains the RAD75EJB project and the RAD75EJBEAR enterprise application.
ibm.com/redbooks