This section describes the procedure to create, assemble, and deploy a Java-based client that is not packaged using the Application Client Container (ACC). This section describes the following topics:
For information about using the ACC, see Developing Clients Using the ACC.
In your client code, instantiate the InitialContext:
InitialContext ctx = new InitialContext();
It is not necessary to explicitly instantiate a naming context that points to the CosNaming service.
In the client code, look up the home object by specifying the JNDI name of the home object.
For example:
Object ref = ctx.lookup("jndi-name"); BeanAHome = (BeanAHome)PortableRemoteObject.narrow(ref,BeanAHome.class);
If load balancing is enabled as in Step 6 and the EJB components being accessed are in a different cluster, the endpoint list must be included in the lookup, as follows:
corbaname:host1:port1,host2:port2,.../NameService#ejb/jndi-name
For more information about naming and lookups, see Accessing the Naming Context.
Deploy the EJB component to be accessed.
For more information on deployment, see Tools for Deployment.
Copy the following JAR files to the client machine and include them in the classpath on the client side:
appserv-rt.jar - available at install-dir/lib
j2ee.jar - available at install-dir/lib
To access EJB components that are residing in a remote system, set the values for the Java Virtual Machine startup options:
jvmarg value = "-Dorg.omg.CORBA.ORBInitialHost=${ORBhost}" jvmarg value = "-Dorg.omg.CORBA.ORBInitialPort=${ORBport}"
Here ORBhost is the Application Server hostname and ORBport is the ORB port number (default is 3700 for the default instance).
This information can be obtained from the domain.xml file on the remote system. For more information on domain.xml file, see the Sun Java System Application Server Enterprise Edition 8.2 Administration Reference.
To set up load balancing and remote EJB reference failover, define the endpoints property as follows:
jvmarg value = "-Dcom.sun.appserv.iiop.endpoints=host1:port1,host2:port2,..." |
The endpoints property specifies a comma-separated list of one or more IIOP endpoints used for load balancing. An IIOP endpoint is in the form host:port, where the host is an IPv4 address or host name, and the port specifies the port number.
If the endpoints list is changed dynamically in the code, the new list is used only if a new InitialContext is created.
As long as the client environment is set appropriately and the JVM is compatible, you merely need to run the main class.
The following sample application demonstrates client load balancing and failover:
install-dir/samples/ee-samples/failover/apps/sfsbfailover
A server-side module can be a servlet, another EJB component, or another type of module.
In your module code, instantiate the InitialContext:
InitialContext ctx = new InitialContext();
It is not necessary to explicitly instantiate a naming context that points to the CosNaming service.
To set up load balancing and remote EJB reference failover, define the endpoints property as follows:
Hashtable env = new Hashtable(); env.put("com.sun.appserv.iiop.endpoints","host1:port1,host2:port2,..."); InitialContext ctx = new InitialConext(env);
The endpoints property specifies a comma-separated list of one or more IIOP endpoints used for load balancing. An IIOP endpoint is in the form host:port, where the host is an IPv4 address or host name, and the port specifies the port number.
If the endpoints list is changed dynamically in the code, the new list is used only if a new InitialContext is created.
In the module code, look up the home object by specifying the JNDI name of the home object. For example:
Object ref = ctx.lookup("jndi-name"); BeanAHome = (BeanAHome)PortableRemoteObject.narrow(ref,BeanAHome.class);
If load balancing is enabled as in Step 1 and the EJB components being accessed are in a different cluster, the endpoint list must be included in the lookup, as follows:
corbaname:host1:port1,host2:port2,.../NameService#ejb/jndi-name
For more information about naming and lookups, see Accessing the Naming Context.
Deploy the EJB component to be accessed.
For more information on deployment, see Tools for Deployment.
To access EJB components that are residing in a remote system, set the values for the Java Virtual Machine startup options:
jvmarg value = "-Dorg.omg.CORBA.ORBInitialHost=${ORBhost}"jvmarg value = "-Dorg.omg.CORBA.ORBInitialPort=${ORBport}"
Here ORBhost is the Application Server hostname and ORBport is the ORB port number (default is 3700 for the default instance).
This information can be obtained from the domain.xml file on the remote system. For more information on domain.xml file, see the Sun Java System Application Server Enterprise Edition 8.2 Administration Reference.
Deploy the module.
For more information on deployment, see Tools for Deployment.
The following sample application demonstrates client load balancing and failover:
install-dir/samples/ee-samples/failover/apps/sfsbfailover
Create a JMS client.
For detailed instructions on developing a JMS client, see the J2EE 1.4 Tutorial at http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JMS.html#wp84181.
Next, configure a JMS resource on the Application Server.
For information on configuring JMS resources, see Creating JMS Resources: Destinations and Connection Factories.
Copy the following JAR files to the client machine and include them in the classpath on the client side:
appserv-rt.jar - available at install-dir/lib
j2ee.jar - available at install-dir/lib
imqjmsra.jar - available at install-dir/lib/install/aplications/jmsra
Set the values for the Java Virtual Machine startup options:
jvmarg value = "-Dorg.omg.CORBA.ORBInitialHost=${ORBhost}" jvmarg value = "-Dorg.omg.CORBA.ORBInitialPort=${ORBport}"
Here ORBhost is the Application Server hostname and ORBport is the ORB port number (default is 3700 for the default instance).
This information can be obtained from the domain.xml file. For more information on domain.xml file, see the Sun Java System Application Server Enterprise Edition 8.2 Administration Reference.
As long as the client environment is set appropriately and the JVM is compatible, you merely need to run the main class.