![]() |
CORBA Interoperability Sample Application |
EJB Accessing Backend CORBA Objects via IONA Orbix
This document describes how to utilize the CORBA Interoperability sample application in conjunction with Sun Java (tm) System Application Server version 7.This sample application document contains the following sections:
Overview
This sample demonstrates how a simple stateless session bean can call methods of a remote CORBA object with IONA E2A platform as the underlying ORB. Since the EJB accesses the "SimpleObject" CORBA object that is part of the Orbix demo applications, you must first run the Orbix demo application in the Orbix environment, before running this Sun Java (tm) System AS (Application Server) sample application. In this sample, a simple servlet is used to access the EJB.This sample also demonstrates the use of a Java client application and RMI/IIOP to call a method of the same EJB that accesses the backend CORBA application. Using RMI/IIOP to access the EJB demonstrates how one can use both Sun Java System and a third party ORB within the same application server instance to support both front-end RMI/IIOP-based access to EJBs and backend CORBA-based access to existing CORBA applications.
Initialization of multiple ORBs in this sample is avoided through the use of a singleton class. Regardless of the number of instances of the stateless session bean created by the EJB container, the singleton approach ensures that at most one instance of the ORB is created for the entire application. To learn more about how the singleton design pattern has been used in this sample, review the Using a Singleton for ORB Initialization document.
Figure 1 depicts the main components of this sample:
Figure 1    CORBA sample Architecture
Setting Up the Environmentl
The Configuring Third Party ORBs with Sun Java (tm) System Application server section describes how to setup and run the Orbix "Simple Object" demo application in a standalone mode prior to following the instructions to run it with Sun Java (tm) System Application Server.
Compiling and Assembling the Application
Although the pre-built XML deployment descriptors are included with the sample, includes preset values of environment setting, these values may not match your ORB installation path. The first step in assembling the sample is to modify the environment settings.There are two locations where you have to modify the settings as per your ORB installation:
Modifying ejb-jar.xml CORBA Environment Settings Settings (Web Deployment descriptor)
After changing the environment settings , go to Compiling and Assembling the Application Using Ant Build. The fastest means of setting up the application is to use the Command Line Interface (CLI)-based Deployment. If you would like to deploy through Admin GUI, then follow instructions for Web Interface (GUI)-based Deployment.Modifying The Build File (build.xml)
Modifying ejb-jar.xml CORBA Environment Settings
The sample web application relies on several J2EE environment settings to access the Orbix ORB domain location and several Interoperable Object Reference (IOR) files. Preset values are included in the pre-built EAR, but these default values are unlikely to suit your ORB installation path. (Since this is a 'simple' sample, IOR files are used in place of dynamic lookups through a CORBA naming service).Table 1 lists the environment settings required by the sample web application. These settings are available in the ejb-jar.xml file, which is under the src/ directory of the sample application. If you are using the Ant Buld Facility to rebuild the sample application, then you can simply change the settings as they appear in the ejb-jar.xml file and rebuild the application.
Modifying these settings in the ejb-jar.xml file is preferred because the changes will be present each time you deploy the application to the application server.
To modify the environment setting in the ejb-jar.xml file, do the following:
Edit <Sun-Java-System-AS-install_dir>/samples/corba/ejbsample/src/ejb-jar.xml
Change the environment settings listed in Table 1 to match your ORB installation:
On Windows:
On Solaris:
- ...
- <env-entry>
- <env-entry-name>orbCfgDir</env-entry-name>
- <env-entry-value>c:\<domain_path>\domains</env-entry-value>
- <env-entry-type>java.lang.String</env-entry-type>
- </env-entry>
- <env-entry>
- <env-entry-name>simpleObjectIor1</env-entry-name>
- <env-entry-value>c:\<orb_installpath>\demos\corba\orb\simple1.ior</env-entry-value>
- <env-entry-type>java.lang.String</env-entry-type>
- </env-entry>
- <env-entry>
- <env-entry-name>simpleObjectIor2</env-entry-name>
- <env-entry-value>c:\<orb_installpath>\demos\corba\orb\simple2.ior</env-entry-value>
- <env-entry-type>java.lang.String</env-entry-type>
- </env-entry>
- ...
- ...
- <env-entry>
- <env-entry-name>orbCfgDir</env-entry-name>
- <env-entry-value>/<domain_path>/domains</env-entry-value>
- <env-entry-type>java.lang.String</env-entry-type>
- </env-entry>
- <env-entry>
- <env-entry-name>simpleObjectIor1</env-entry-name>
- <env-entry-value>/<orb_installpath>/demos/corba/orb/simple1.ior</env-entry-value>
- <env-entry-type>java.lang.String</env-entry-type>
- </env-entry>
- <env-entry>
- <env-entry-name>simpleObjectIor2</env-entry-name>
- <env-entry-value>/<orb_installpath>/demos/corba/orb/simple2.ior</env-entry-value>
- <env-entry-type>java.lang.String</env-entry-type>
- </env-entry>
- ...
Modifying The Build File
Before recompilation and reassembling the sample, you will need to modify the build file to reflect the installation location of your ORB.
Under the directory <Sun-Java-System-AS-install_dir>/samples/corba/ejbsample/src/
These modifications will enable you to easily compile and reassemble the sample application. If you don't make this change, the servlet source code will not compile because it will not be able to access the OMG ORB classes.Edit the build.xml file by modifying the following property to suit your ORB installation environment:
Compiling and Assembling the Application Using Ant Build
To compile and assemble the application using Ant Build Facility, do the following:
On UNIX, prior to executing the build command, you need to ensure that <Sun-Java-System-AS-install_dir>/bin is in your PATH.
Executing the build command will compile the application source files and reassemble both the WAR and EAR files. The EAR file will be placed in <Sun-Java-System-AS-install_dir>/samples/corba/ejbsample/assemble/ear/.Rebuild the application by executing the asant command under the <Sun-Java-System-AS-install_dir>/samples/corba/ejbsample/src/ directory. For example:
You are now ready to follow either the Command Line Interface (CLI)-based Deployment or Web Interface (GUI)-based Deployment instructions.
Deploying the Sample
After compiling and assembling the application, you can choose to deploy and register the application through either command line utilities or Sun Java (tm) System Application Server Admin GUI. The deployment procedure is same for Windows and Solaris platforms.
Command Line Interface (CLI)-based Deployment
Once you've modified the CORBA environment settings, deploying the newly built corba-ejbsample.ear file is simple.
Go to the directory in which the newly assembled EAR file is located. For example: <Sun-Java-System-AS-install_dir>/samples/corba/ejbsample/assemble/ear
If you would like to verify the registration of the application, proceed to Verifying Registration. Otherwise, you're ready to exercise the application by Running the Sample Application.Before executing the command line deploy utility, ensure that you have <Sun-Java-System-AS-install_dir>/bin in your PATH.
Execute iasadmin to deploy application to the particular application server instance. For example:
Alternatively, under the src/ directory, you can execute following command to deploy the application to the default application server instance installed on localhost.
Web Interface (GUI)-based Deployment
The Sun Java (tm) System Admininstration Tool GUI provides an easy way of deploying applications to Sun Java (tm) System Application Server.
Note Before proceeding, you must ensure that the application is repackaged with modified deployment descriptors containing the environment setting in accordance with your ORB installation.
Since a prebuilt Enterprise Archive (EAR) file for the sample application is included with the application server, you can deploy it to the application server if your ORB installation is set to default or first build the application using Ant Build Facility and use this EAR file for deployment.
Open the browser and go to the admin server. For example:
If you have deployed the application successfully, this application will be listed under Deployed Applications. After the application is deployed you can proceed to Running the Sample Application.Login as Admin user.
Go to Application Server Instances -> server1 (or any other instance) -> Applications
Click on the Deploy tab to deploy your application.
- Click on the link Enterprise Applications.
- You will see the deployed j2ee applications on this server instance here.
Give the absolute location of your Application EAR file
Click OK.
- or
- Navigate to <Sun-Java-System-AS-install_dir>/samples/corba/ejb/assemble/ear and open the corba-ejbsample.ear file.
After uploading your application EAR file, the GUI will ask you for a AppName.
Verifying Registration
To verify the registration of the application, do the following:
In the Admin GUI go to Application Server Instances -> server1 (or any other instance) -> Applications.
Click on the link Enterprise Applications.
You can also execute the iasadmin command to look at applications deployed with a server instance. For example:
Running the Sample Application
Prior to running the sample, ensure that you have performed the following steps:
Run the Orbix SimpleObject sample in standalone mode outside of Sun Java (tm) System Application Server.
Refer to the E2A Application Server Platform 5.1 Configuration to see how to setup and run the Orbix "SimpleObject" demo application in a standalone mode prior to running the servlet application in the application server.
After you've started the Orbix services and the server side CORBA object, run the application by accessing:
You should see the following output in your browser:
Figure 2    Servlet calling EJB to access backend CORBA server
Running the RMI/IIOP Client Application
This section demonstrates an RMI/IIOP-based client calling the business method of an EJB that in turn calls a method of a backend
CORBA component. This scenario is particularly interesting as you will be using the Sun Java System ORB to support the front-end RMI/IIOP access
and the Orbix ORB to support the backend CORBA access.Deploy the Client Application
To Run the RMI client set JAVA_HOME and PATH variables to <JDK-1.4-install-dir> and <JDK-1.4-install-dir>/bin. Classpath must contain appserv-ext.jar and corba-ejbsampleClient.jar
java -cp <Sun-Java-System-AS-install_dir>/domains/<domain_name>/<server_name>/applications/j2ee-apps/corba-ejbsample_1/corba-ejbsampleClient.jar:<Sun-Java-System-AS-install_dir>/lib/appserv-ext.jar samples.corba.ejbsample.RmiClient <hostname> <orb-port>Where:<hostname> is the host name of the Sun Java (tm) System Application Server.
<orb-port> is the IIOP port number of the IIOP Listener on the Sun Java (tm) System Application Server instance. default is 3700
The application should produce the following messages:Client side:Call of corbaClinet.doWork() was a success.
Server logs :
[16/Apr/2002:23:55:25] INFO (11019): CorbaClientEJB: doWork() started on obj samples.corba.ejbsample.ejb.CorbaClientEJB@6270b
[16/Apr/2002:23:55:25] INFO (11019): CorbaClientEJB: Invoking method on first object.
[16/Apr/2002:23:55:25] INFO (11019): CorbaClientEJB: Invoking method on second object.
[16/Apr/2002:23:55:25] INFO (11019): CorbaClientEJB: doWork() finished on obj samples.corba.ejbsample.ejb.CorbaClientEJB@6270bTroubleshooting
Although the sample web application contains limited exception handling, it should provide you with a sense of some of the failure scenarios and basic recovery techniques that apply when accessing remote CORBA objects from within the application server.
Ejb Initialization Failures
Ejb may issue a EjbException during the ejbCreate() method due to any one of the following actions:
By not including the Orbix classes in the application server's CLASSPATH
By renaming or deleting one or more of the environment settings contained in the web application
Post Initialization Failures
If you stop the server side CORBA object server and rerun the servlet application, you will notice that the servlet will catch the CORBA exceptions and attempt to reinitialize object references. These attempts will fail until you restart the CORBA object server.Upon restarting the CORBA object server and attempting to rerun the servlet application, you should observe that the client successfully reinitializes the object references and access the remote methods.
Run time errors
Ensure that you've started the Orbix services as well as the CORBA server prior to running the application.The following errors are described in this section:
org.omg.CORBA.OBJ_ADAPTER Error
If you encounter the following messages in the Server log file, then you have not configured the application server to use the Orbix ORB classes. Refer to the E2A Application Server Platform 5.1 Configuration document for more details.Retrieving JNDI initial context
Looking up CorbaClient bean home interface
Looking up: java:comp/env/ejb/TheCorbaClient
Calling CorbaClient bean to do some work.
aught RemoteException while calling EJB business method: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: nested exception is:
java.rmi.RemoteException: Call to first CORBA method failed.; nested exception is:
java.rmi.RemoteException: Call to first CORBA method failed.
Result of calling CorbaClient bean: failure
[16/Apr/2002:23:36:17] INFO (11001): CorbaClientEJB: doWork() started on obj samples.corba.backend.orbix.ejb.bean.CorbaClientEJB@b28980
[16/Apr/2002:23:36:17] INFO (11001): CorbaClientEJB: Invoking method on first object.
[16/Apr/2002:23:36:17] INFO (11001): creating connection to EndPoint: EndPoint
[IIOP_CLEAR_TEXT:129.158.228.203:38978:false]
[16/Apr/2002:23:36:17] INFO (11001): Caught exception: org.omg.CORBA.OBJ_ADAPTER: vmcid: SUN minor code: 202 completed: No (Minor code meaning not found)
[16/Apr/2002:23:36:17] SEVERE (11001): "EJB5018: Some unmapped exception occurred : javax.ejb.EJBException: nested exception is: java.rmi.RemoteException: Call to first CORBA method failed."
[16/Apr/2002:23:36:17] SEVERE (11001): "EJB5019: Some application or system exception occurred : java.rmi.RemoteException: nested exception is: java.rmi.RemoteException: Call to first CORBA method failed.; nested exception is:
java.rmi.RemoteException: Call to first CORBA method failed."
[16/Apr/2002:23:36:18] INFO (11001): Caught RemoteException while calling EJB business method:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
[16/Apr/2002:23:36:18] INFO (11001): java.rmi.RemoteException: nested exception is:
java.rmi.RemoteException: Call to first CORBA method failed.; nested exception is:
[16/Apr/2002:23:36:18] INFO (11001): java.rmi.RemoteException: Call to first CORBA method failed.
[16/Apr/2002:23:36:18] INFO (11001): Result of calling CorbaClient bean: failure
LICENSE_FILE_NOT_AVAIL/org.omg.CORBA.INITIALIZE
Double check the CLASSPATH of the application server to ensure that the name of the directory under which the licenses.txt file is located is part of the CLASSPATH. Refer to the E2A Application Server Platform 5.1 Configuration document for more details.Retrieving JNDI initial context
Looking up CorbaClient bean home interface
Looking up: java:comp/env/ejb/TheCorbaClient
Calling CorbaClient bean to do some work
Caught RemoteException while calling EJB business method:java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException; nested exception is: javax.ejb.EJBException: nested exception is:
javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException
Result of calling CorbaClient bean: failure
[16/Apr/2002:21:51:43] SEVERE (10930): "EJB5070: Exception creating stateless session bean : java.lang.reflect.InvocationTargetException"
[16/Apr/2002:21:51:43] SEVERE (10930): ejb.preinvoke_exception
[16/Apr/2002:21:51:43] SEVERE (10930): "EJB5018: Some unmapped exception occurred : javax.ejb.EJBException: nested exception is: javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException"
[16/Apr/2002:21:51:43] SEVERE (10930): "EJB5019: Some application or system exception occurred : java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException; nested exception is:
javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException"
[16/Apr/2002:21:51:43] INFO (10930): Caught RemoteException while calling EJB business method: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: [16/Apr/2002:21:51:43] INFO (10930): java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB:
java.lang.reflect.InvocationTargetException; nested exception is: [16/Apr/2002:21:51:43] INFO (10930): javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException [16/Apr/2002:21:51:43] INFO (10930): Result of calling CorbaClient bean: failure
CORBA.TRANSIENT exception
Ensure that the demos.simple.Server application has been started. Refer to the E2A Application Server Platform 5.1 Configuration document for more details. Upon restarting the CORBA server application and executing the servlet again, the servlet should work properly.[16/Apr/2002:21:42:21] INFO (10901): CorbaClientEJB: doWork() started on obj samples.corba.ejbsample.ejb.CorbaClientEJB@9b4fac
[16/Apr/2002:21:42:21] INFO (10901): CorbaClientEJB: Invoking method on first object.
[16/Apr/2002:21:42:22] INFO (10901): Caught org.omg.CORBA.TRANSIENT exception.org.omg.CORBA.TRANSIENT: cannot establish binding vmcid:
0x49540000 minor code: 770 completed: No[16/Apr/2002:21:42:22] INFO (10901): CorbaClientEJB: Trying to reinitialize object refs.
[16/Apr/2002:21:42:22] INFO (10901): CorbaClientEJB: Invoking narrow on second object.
[16/Apr/2002:21:42:22] INFO (10901): CorbaClientEJB: Invoking method on second object.
[16/Apr/2002:21:42:22] INFO (10901): Caught org.omg.CORBA.TRANSIENT exception.
[16/Apr/2002:21:42:22] INFO (10901): org.omg.CORBA.TRANSIENT: cannot establish binding vmcid: 0x49540000 minor code: 770 completed: No
[16/Apr/2002:21:42:22] INFO (10901): CorbaClientEJB: Trying to reinitialize object refs.
[16/Apr/2002:21:42:22] INFO (10901): CorbaClientEJB: doWork() finished on obj samples.corba.ejbsample.ejb.CorbaClientEJB@9b4fac
[16/Apr/2002:21:42:22] INFO (10901): Result of calling CorbaClient bean: failure
Class Cast Exception
Ensure that the demos.simple.Server application has been started. Refer to the E2A Application Server Platform 5.1 Configuration document for more details. Upon restarting the CORBA server application and executing the servlet again, the servlet should work properly. The cause of this problem is likely the same as the cause of the CORBA.TRANSIENT exception, but the circumstances of the timing are different.
Previous Contents Next
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated August 09, 2002