
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:
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.
You must have set a reference between your Web Module project and the EJB Module project that contains the enterprise bean you set reference to. To do that, choose Properties from the context menu for your Web Module project, and then choose Project References in the window that appears. Choose the appropriate EJB Module project from the list.
If you try to add an EJB reference without setting the reference between the projects, you get an error message and the reference is not created.
Configuring EJB and EJB Local References as Application-scoped Resources
On the web.xml screen, proceed as follows:
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.
| 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 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. |
Configuring EJB and EJB Local References as External Resources
After completing this procedure, you have defined the EJB references that are to be bound to your Web application's naming environment.
For more information about how to set the application reference, see Editing Application References .