Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.5.0) Part Number E13981-01 |
|
|
View PDF |
Before you can access an enterprise bean from a client, you must consider the following:
Table 29-1 lists the OC4J-specific JAR files that you must install on the client depending on what your client looks up. The Source column indicates from where you get a copy of the required JAR from <
OC4J_HOME
>
.
Only the oc4jclient.jar
should be on the client classpath. All other JAR files required by the client are referenced in the oc4jclient.jar
manifest classpath.
Table 29-1 OC4J Client Classpath Requirements
OC4J JAR | Source (Relative to <OC4J_HOME>) | EJB Lookup | JMS Connector Lookup | OEMS JMS Lookup | OEMS JMS Database Lookup |
---|---|---|---|---|---|
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
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 enterprise bean, 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: standalone, or as part of Oracle Application Server (see "Configuring the Initial Context Factory").
If the client and target enterprise bean 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 enterprise bean (see "Specifying Credentials in EJB Clients").
In EJB 3.0, to access an EJB 3.0 enterprise bean 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 lookup with a predefined environment references.
In EJB 2.1 or in EJB 3.0 (for standalone Java clients), to access an enterprise bean or resource, you must do a JNDI lookup on a predefined environment references (see "Configuring Environment References"). To access an EJB 2.1 enterprise bean 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 enterprise bean 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 enterprise bean, see "EJB Environment References".
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 enterprise bean with logical name ejb/HelloWorld
using the java:comp/env/ejb/
prefix, and Example 29-2 shows how to look up this enterprise bean without the prefix.