IBM


13.3.1 Defining EJB JNDI names

For each session and entity bean, specify a JNDI name. This name is used to bind the EJB home object to an entry in the global JNDI name space. The bind happens automatically when the appserver starts.

You can bind your EJBs anywhere you want in the JNDI name space, but best practice dictates they should be bound under the ejb subcontext, such as ejb/Order for the Order EJB. However, the Plants by WebSphere binds its EJBs to the plantsby subcontext in the JNDI root, so this is what we will show you here.

For clarity, however, when developing your own application, we recommend that you place all enterprise bean JNDI names for an application in a separate subcontext, such as ejb/PlantsBy. You can find the JNDI names for the Plants by WebSphere session and entity EJBs in Table 13-1.

Table 13-1 Plants by WebSphere enterprise bean JNDI names

EJB Name JNDI Name
BackOrder entity bean plantsby/BackOrderHome
Customer entity bean plantsby/CustomerHome
IdGenerator entity bean plantsby/IdGeneratorHome
Inventory entity bean plantsby/InventoryHome
Order entity bean plantsby/OrderHome
OrderItem entity bean plantsby/OrderItemHome
Supplier entity bean plantsby/SupplierHome
Back Order Stock Session EJB plantsby/BackOrderStockHome
Catalog Session EJB plantsby/CatalogHome
Login Session EJB plantsby/LoginHome
Mailer Session EJB plantsby/MailerHome
Report Generator Session EJB plantsby/ReportGeneratorHome
Reset Database Session EJB plantsby/ResetDBHome
Shopping Cart Session EJB plantsby/ShoppingCartHome
Suppliers plantsby/SuppliersHome

Use this table and the instructions below to define a JNDI name for each Plants by WebSphere enterprise bean:

1. In the Project Explorer view, expand the EJB Projects section.

2. Expand the PlantsByWebSphereEJB project and then double-click the Deployment Descriptor (2.1 PlantsByWebSphere EJB Module).

3. Click the Bean tab, and then click the BackOrder EJB. The EJB deployment descriptor is shown in Figure 13-9.

4. Look for the WebSphere Bindings section in the editor. In the JNDI name field, enter plantsby/BackOrderHome.

Figure 13-9 Defining EJB JNDI names

5. Repeat these steps for each of the session and entity enterprise beans in the EJB module.

6. Save the deployment descriptor.


Redbooks ibm.com/redbooks

Next