Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.5.0) Part Number E13981-01 |
|
|
View PDF |
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 enterprise bean, 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 in which you are using it, 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 enterprise bean are collocated |
Default (see "Configuring the Default Initial Context Factory") |
Any Client |
Client and target enterprise bean are deployed in the same application |
Default (see "Configuring the Default Initial Context Factory") |
Any Client |
Target enterprise bean deployed in an application that is designated as the client's parentFoot 1 |
Default (see "Configuring the Default Initial Context Factory") |
Client and target enterprise bean are not collocated, not deployed in the same application, and target EJB application is not client's parentFootref 1. |
|
|
Client and target enterprise bean 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 the following:
Oracle Containers for J2EE Security Guide
Oracle Containers for J2EE Services Guide.
A client that is collocated with the target bean (see Table 19-2) automatically accesses the JNDI properties for the node. Thus, accessing the enterprise bean 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 Enterprise Bean".
Define the java.naming.factory.initial
property with the Oracle initial 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-22 shows.
When you instantiate the initial context, pass the HashTable
into the initial context constructor, as Example 19-23 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="6100" remote="6200" request="6003"/> ... </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 host name is dpanda-us
, request port is 6003, and instances name is home1
, then the provider URL would be:
opmn:ormi://dpanda-us:6003:home1/ejbsamples
For more information, see the following:
"Setting JNDI Properties for RMI" in the Oracle Containers for J2EE Services Guide
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 host name is dpanda-us
, ORMI port is 23793, and the application name is ejb30slsb
, then the provider URL would be:
ormi://dpanda-us:23793/ejb30slsb
For more information, see the following:
"Setting JNDI Properties for RMI" in the Oracle Containers for J2EE Services Guide