|
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3) B14428-01 |
|
![]() Previous |
![]() Next |
Before you can access an EJB from a client, you must consider the following:
Table 29-1 lists the OC4J-specific JAR files that you must include on your client's classpath. The Source column indicates from where you get a copy of the required JAR.
Table 29-1 OC4J Client Classpath Requirements
| OC4J JAR | Source | All Clients | OracleAS JMS Client | Oracle AQ JMS Client | J2CA JMS Client |
|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
J2CA connector JAR |
Connector provider |
|
|
|
|
Footnote 1 Required only if you plan to use the opmn:ormi prefix in JNDI look up with Context.PROVIDER_URL (see "Configuring an Oracle Initial Context Factory").
If you download any of these JAR files into a browser, you must grant certain permissions (see "Granting Permissions in Browser").
You use an initial context factory to obtain an initial context: a reference to the JNDI namespace. Using the initial context, you can use the JNDI API to look up an EJB, resource manager connection factory, environment variable, or other JNDI-accessible object. The type of initial context factory you use depends on your client type and how you are using OC4J: stand-alone or as part of Oracle Application Server (see "Configuring the Initial Context Factory").
If the client and target EJB are not collocated, not deployed in the same application, and the target EJB application is not the client's parent, then your client must specify its credentials before accessing the target EJB ( see "Specifying Credentials in EJB Clients").
In EJB 3.0, to access an EJB 3.0 EJB or resource in an EJB client, you can use annotations, resource injection, and default JNDI names (based on class and interface names) instead of doing a JNDI look up with a predefined environment references.
In EJB 2.1 or in EJB 3.0 (for stand-alone Java clients or servlet or JSP clients), to access an EJB or resource, you must do a JNDI look up on a predefined environment references (see "Configuring Environment References"). To access an EJB 2.1 EJB or resource, choose the appropriate predefined environment reference (actual or logical; local or remote) and look it up using a JNDI initial context (see "Selecting an Initial Context Factory Class").
If you access an EJB by reference from within your client implementation, perform a JNDI lookup using the <ejb-ref-name> defined in the EJB deployment descriptor. For more information on defining an EJB reference to a target EJB, see "Configuring an Environment Reference to an EJB".
Table 29-2 shows when to prefix the reference with java:comp/env/ejb/, which is where the container places the EJB references defined in the deployment descriptor.
Table 29-2 When to Use the java:comp/env/ejb/ Prefix
| Client | Initial Context Factory | Use Prefix? |
|---|---|---|
|
|
Default |
Optional |
|
|
Not Used |
|
|
|
Default |
Optional |
|
|
Mandatory |
|
|
|
Default |
Optional |
|
|
Not Used |
Example 29-1 shows how to look up an EJB with logical name ejb/HelloWorld using the java:comp/env/ejb/ prefix and Example 29-2 shows how to look up this EJB without the prefix.