JNDI can also be used to access an EJB but using this technique is not as easy as DI. The
Salutation EJB from the first recipe and the servlet from the second recipe are used to illustrate this technique.
To use JNDI in a client:
Familiarize yourself with the
Salutation session bean and its two methods as developed in the Creating a Simple Session EJB recipe. We will also modify the
SalutationServlet from the second recipe to use JNDI instead of DI.
A portable JNDI name syntax has been added to EJB 3.1. We will use this syntax as it makes the use of JNDI less dependent on the deployment server.
The modification of the ...