Accessing an EJB from a Java Application using JNDI
It would be nice if we could use dependency injection outside of a server container. However, this is not possible from a Java SE application unless we use an embeddable container. Using an embeddable container is covered in the next recipe. Here we need to use JNDI. Accessing an EJB from a Java SE application using JNDI is similar to using JNDI in other types of applications.
To use this approach we need:
- A supporting EJB
- JNDI code to obtain a reference to the EJB
We will be using the
CapitalApplicationdeveloped in the Accessing an EJB from an Applet recipe found in this chapter. This recipe uses a
CapitalBeanto return the name of the capital given a state. Make sure the server ...