About application clients

An application client uses JNDI to look up and gain access to EJB components, resources, and environment properties defined in an XML deployment descriptor. You can code the application client like a standalone EJB client. However, since the application client is packaged with a deployment descriptor, you can alias the JNDI names used in code to different names when deploying to different servers.

An application client connects to an EAServer component using a JNDI environment naming context. Here is a simple implementation of an application client:

InitialContext initCntxt = new InitialContext();

Object acctRef =    initCntxt.lookup(“java:comp/env/ejb/acctBean”);
acctBeanHome home = (acctBeanHome)
   PortableRemoteObject.narrow(acctRef,
   acctBeanHome.class);
Account acct = home.findByPrimaryKey(new
   AcctPK(1));
String name = acct.getName();
System.out.println(name);

The application client JAR file includes a deployment descriptor that defines the JNDI environment naming context entries. This example defines the EJB reference for an acctBean:

<application-client>
 <display-name>MyClient</display-name>
 <ejb-ref>
   <ejb-ref-name>ejb/AcctBean</ejb-ref-name>
   <ejb-ref-type>Entity</ejb-ref-type>
   <home>com.sybase.acct.acctBeanHome</home>
   <remote>com.sybase.acct.Account</remote>
 </ejb-ref>
</application-client>