|
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3) B14428-01 |
|
![]() Previous |
![]() Next |
You use an initial context factory to obtain an initial context: a reference to a 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 the type of client you are using it in as Table 19-2 shows.
Table 19-2 Client Initial Context Requirements
| Client Type | Relationship to Target EJB | Initial Context Factory |
|---|---|---|
|
Any Client |
Client and target EJB are collocated |
Default (see "Configuring the Default Initial Context Factory") |
|
Any Client |
Client and target EJB are deployed in the same application |
Default (see "Configuring the Default Initial Context Factory") |
|
Any Client |
Target EJB deployed in an application that is designated as the client's parentFoot 1 |
Default (see "Configuring the Default Initial Context Factory") |
|
|
Client and target EJB are not collocated, not deployed in the same application, and target EJB application is not client's parentFootref 1. |
|
|
|
Client and target EJB are not collocated, not deployed in the same application, and target EJB application is not client's parentFootref 1. |
|
Footnote 1 See the Oracle Containers for J2EE Developer's Guide for more information on how to set the parent of an application.
|
Note: In this release, note the new package names for the RMI and application client initial context factories. |
For more information, see:
A client that is collocated with the target bean (see Table 19-2) automatically accesses the JNDI properties for the node. Thus, accessing the EJB is simple: no JNDI properties are required.
If your client requires an Oracle initial context factory (see Table 19-2), you must set the following JNDI properties:
For more information about setting JNDI properties, see "Setting JNDI Properties in an EJB".
Define the java.naming.factory.initial property with the Oracle inital context factory appropriate for your client (see Table 19-2).
Define the java.naming.provider.url property with the naming provider URL appropriate for your OC4J installation:
Create a HashTable and populate it with the required properties using javax.naming.Context fields as keys and String objects as values as Example 19-17 shows.
When you instantiate the initial context, pass the HashTable into the initial context constructor as Example 19-18 shows.
Use the initial context to look up a JNDI-accessible resource:
In an Oracle Application Server install, OPMN manages one or more OC4J instances. In this case the value for java.naming.provider.url should be of the format:
opmn:ormi://<hostname>:<opmn-request-port>:<oc4j-instance-name>/<application-name>
The fields in this provider URL are defined as follows:
<hostname>: The name of the host on which the Oracle Application Server is running.
<opmn-request-port>: In this configuration, you have to use the OPMN request port instead of using the ORMI port. You can find the OPMN request port in the opmn.xml file, as follows:
<notification-server> <port local="6003" remote="6200" request="6004"/> ... </notification-server>
The default OPMN request port is 6003.
<oc4j-instance-name>: In this configuration, you may have more than one OC4J process that OPMN uses for load balancing/failover. You use the name of the instance to which you deployed your application.
The default instance name is home.
For example, if the hostname is dpanda-us, request port is 6004, and instances name is home1, then the provider URL would be:
opmn:ormi://dpanda-us:6003:home1/ejbsamples
In a standalone OC4J install, the value for java.naming.provider.url should be of the format:
ormi://<hostname>:<ormi-port>/<application-name>
The fields in this provider URL are defined as follows:
<hostname>: The name of the host on which OC4J is running
<ormi-port>: The ORMI port as configured in the rmi.xml file, as follows:
<rmi-server xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/rmi-server-10_0.xsd" port="23791" schema-major-version="10" schema-minor-version="0" > ... </rmi-server>
The default port is 23791.
<application-name>: The application name as configured in the server.xml file.
For example, if the hostname is dpanda-us, ORMI port is 23793, and the application name is ejb30slsb, then the provider URL would be:
ormi://dpanda-us:23793/ejb30slsb