Adding an EJB Reference to a Web Application

Servlets and JSPs use EJB references to instantiate proxies for EJB home interfaces. EJB references must be cataloged in the deployment descriptor so the Web application can run independent of a specific naming configuration. When deploying the Web application, a site administrator can map site-specific EJB JNDI names to the references used by the Web application.

Servlets and JSPs can look up an EJB by specifying the reference name prefixed with j ava:comp/env/. For example, if you enter ejb/catalog in EAServer Manager, use java:comp/env/ejb/catalog in your JSP or servlet source code.

  1. In the WorkSpace Navigator of the Web Application Development perspective, select web.xml.
  2. Select the EJB tab.
  3. Expand EJB References.
  4. To add a new reference, click Add. General Information displays to the right of the References section.
  5. Change the default EJB name in the Name field of the General Information section. The name specifies the JNDI name used in your code to refer to the called EJB. The aliased name is displayed in the Link Value field. Enter the part of the JNDI name that begins with ejb/. For example, if your code refers to java:comp/env/ejb/MyBean, type ejb/MyBean.
  6. (Optional) Enter a link.
  7. Click the arrow in the Type field to select either Entity for entity beans or Session for session beans.
  8. Click Browse adjacent to the Home field and select the Java class name of the EJB remote interface, specified in dot notation. Example: com.sybase.MyBeanHome.
  9. Click Browse adjacent to the Remote field and select the Java class name of the EJB home interface, specified in dot notation. Example: com.sybase.MyBeanRemote.
  10. (Optional) Type a description of the EJB reference.
  11. (EAServer Only) If you are using EAServer, in the WorkSpace Navigator, expand webroot, expand META-INF, and select sybase-easerver-config.xml. You must modify this file to the actual JNDI name EJB component that is installed in the server where your component, Web application, or application client is to be deployed. This is specified by the JNDI Name property in the Component Properties of the called EJB component.
Related concepts
Configuring the web.xml File
Related tasks
Adding a Servlet to a Web Application
Adding a Filter to a Web Application
Adding a Resource Reference to a Web Application
Adding a Context Parameter to a Web Application
Adding a Listener to a Web Application
Adding a Tag Library to a Web Application
Adding a Welcome File to a Web Application
Adding an Error Page to a Web Application
Adding MIME Mapping to a Web Application
Adding an EJB Local Reference to a Web Application
Adding a Resource Environment Reference to a Web Application
Adding an Environment Entry to a Web Application
Adding Security to a Web Application
Defining the Login Configuration of a Web Application

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.