Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3)
B14428-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Configuring the Client

Before you can access an EJB from a client, you must consider the following:

Configuring the Client Classpath for OC4J

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

oc4jclient.jar

<OC4J_HOME>/j2ee/<instance>

Supported
Supported
Supported
Supported

ejb.jar

<OC4J_HOME>/j2ee/<instance>/lib

Supported
Supported
Supported
Supported

jndi.jar

<OC4J_HOME>/j2ee/<instance>/lib

Supported
Supported
Supported
Supported

optic.jarFoot 1 

<OC4J_HOME>/opmn/lib

Supported
Supported
Supported
Supported

jta.jar

<OC4J_HOME>/j2ee/<instance>/lib

Not Supported
Supported
Supported
Supported

jms.jar

<OC4J_HOME>/j2ee/<instance>/lib

Not Supported
Supported
Supported
Supported

javax77.jar

<OC4J_HOME>/j2ee/<instance>/lib

Not Supported
Supported
Supported
Supported

adminclient.jar

<OC4J_HOME>/j2ee/<instance>/lib

Not Supported
Not Supported
Supported
Not Supported

jdbc.jar

<OC4J_HOME>/j2ee/<instance>/../../lib

Not Supported
Not Supported
Supported
Not Supported

dms.jar

<OC4J_HOME>/j2ee/<instance>/lib

Not Supported
Not Supported
Supported
Not Supported

J2CA connector JAR

Connector provider

Not Supported
Not Supported
Not Supported
Supported

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").

Selecting an Initial Context Factory Class

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").

Specifying Security Credentials

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").

Selecting an EJB Reference

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?

EJB Client


Default

Optional

RMIInitialContext

Not Used

Stand-alone Java Client


Default

Optional

ApplicationClientInitialContext

Mandatory

Servlet or JSP Client


Default

Optional

RMIInitialContext

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.

Example 29-1 Looking Up an EJB with the Prefix

InitialContext ic = new InitialContext();
HelloHome hh = (HelloHome)ic.lookup("java:comp/env/ejb/HelloWorld");

Example 29-2 Looking Up an EJB without the Prefix

InitialContext ic = new InitialContext();
HelloHome hh = (HelloHome)ic.lookup("ejb/HelloWorld");