In the post, I will write about how to accessing a bean in EJB.
Accessing deployed beans is simple. First write the the client code and set up JNDI environment settings for the client. It can be done via a JNDI properties file. Now you have to set the class path for the client and add the following file locations to it:
jboss-client.jar, jnp-client.jar, EJB interfaces, and the directory where the JNDI properties file is stored
Remember, two JNDI settings
JNDI is a standard Java API that comes with JDK 1.3 and higher. It provides a common interface to a variety of existing naming services for example DNS, LDAP, Active Directory, RMI registry, COS registry, NIS, and file systems.
The JNDI API is divided logically into a client API and service provider interface. Client API is used to access naming services and a SPI allows the user to create JNDI implementations for naming services.
The naming service providers must implement
JNDI API package is called javax.naming package. It is composed of 5 interfaces, 10 classes along with few exceptions. InitialContext is the key class.
This is what Sun Java Docs say about InitialContext: Java 2 Platform SE v1.3.1: Package javax.naming
In JNDI, all naming and directory operations are performed relative to a context. There are no absolute roots. Therefore JNDI defines an initial context, InitialContext, which provides a starting point for naming