Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (10.1.3.5.0)

Part Number E13981-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Configuring the Client

Before you can access an enterprise bean 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 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

adminclient.jar

/j2ee/<instance>/lib

Not Supported Supported Not Supported Supported

bcel.jar

/j2ee/<instance>/lib

Not Supported Not Supported Not Supported Supported

connector.jar

/j2ee/<instance>/lib

Not Supported Supported Not Supported Not Supported

dms.jar

/j2ee/<instance>/lib

Not Supported Not Supported Not Supported Supported

ejb.jar

/j2ee/<instance>/lib

Supported Not Supported Not Supported Supported

javax77.jar

/j2ee/<instance>/lib

Not Supported Supported Supported Supported

jazncore.jar

/j2ee/<instance>

Not Supported Supported Not Supported Not Supported

jdbc.jar

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

Not Supported Not Supported Not Supported Not Supported

jms.jar

/j2ee/<instance>/lib

Not Supported Supported Supported Supported

jmxri.jar

/j2ee/<instance>/lib

Not Supported Supported Not Supported Not Supported

jndi.jar

/j2ee/<instance>/lib

Not Supported Supported Supported Supported

jta.jar

/j2ee/<instance>/lib

Not Supported Supported Supported Supported

oc4j.jar

/j2ee/<instance>

Not Supported Supported Not Supported Not Supported

oc4jclient.jar

/j2ee/<instance>

Supported Supported Supported Supported

oc4j-internal.jar

/j2ee/<instance>/lib

Not Supported Supported Not Supported Not Supported

ojdbc14dms.jar

/j2ee/<instance>/../../oracle/jdbc/lib

Not Supported Not Supported Not Supported Supported

optic.jarFoot 1 

/opmn/lib

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

Specifying Security Credentials

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

Selecting an EJB Reference

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?

EJB Client

Default

RMIInitialContext

Optional

Not Used

Standalone Java Client

Default

ApplicationClientInitialContext

Optional

Mandatory

Servlet or JSP Client

Default

RMIInitialContext

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.

Example 29-1 Looking Up an Enterprise Bean With the Prefix

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

Example 29-2 Looking Up an Enterprise Bean Without the Prefix

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