!--a11y-->
Configuring Enterprise Bean References 
Enterprise bean references are a special type of environment entry. They refer to the home (or local home) interface of the target enterprise bean. You can configure two types of enterprise bean references:
· EJB references
· EJB local references
If the enterprise beans that you are referencing are to be deployed as part of the same enterprise application as your Web application, then you configure the references in the web.xml descriptor only. If, however, the enterprise beans are “external” to your Web application, you have to set a reference at classloader level using the application-j2ee-engine.xml descriptor, in addition to the configuration of the reference you specify in the web.xml.
On the web.xml screen, proceed as follows:
...
1. Open the EJBs screen.
2. If you want to add EJB reference, choose Add from the EJB references pane.

If you want to add EJB local reference, you must do the same as for the EJB references but within the EJB local references pane.
3. Choose the enterprise bean that you want to reference from the Choose EJBs screen that appears.
4. The SAP NetWeaver Developer Studio automatically completes all fields defining the reference (except for the Description) based on the information from your EJB project. However, you can modify the following fields to reflect the specifics of your Web application:
Field |
Description |
Reference Name |
Enter the name of the reference in this field. This is the JNDI name that you use in your servlet (or JSP) code to refer to that enterprise bean. This name is stored relative to the java:comp/env context. |
Description |
This field is optional. You can enter a description of the EJB reference in it. |
EJB Link |
You can specify the name of the references bean (exactly as defined in the ejb-jar.xml) to link the reference to it.
You can use EJB Link only for references to enterprise beans that are part of the same enterprise application as your Web application. If beans are deployed externally, you have to define the link in the web-j2ee-engine.xml descriptor. If the name of the target enterprise bean is not unique in the enterprise application scope, you can enter the path to the JAR file that contains the bean (relative to the WAR file of the referencing Web application), add the # symbol at the end of it, and then enter the name of the target bean. |
...
1. To configure EJB reference for external enterprise beans, repeat the same procedure as with EJB references when the enterprise beans are application-scoped. You must not set anything in the EJB Link field.
After completing this procedure, you have defined the EJB references that are to be bound to your Web application’s naming environment.
2. In the application-j2ee-engine.xml descriptor of your Enterprise Application Project, define a reference to the application the referenced enterprise beans are part of. This sets reference between the two application classloaders and enables classes of the referenced application to be loaded and used by your referring Web application.
For more information about how to set the application reference, see Editing Application References.
