![]() |
CORBA Interoperability Sample Application |
Servlets Accessing Backend CORBA Objects via IONA Orbix
This document describes how to utilize the CORBA Interoperability sample application in conjunction with Sun ONE Application Server version 7.This sample application document contains the following sections:
Overview
This example application demonstrates how a very simple servlet can call methods of a remote CORBA object based on using Orbix as the underlyingORB. Since the servlet accesses the "SimpleObject" CORBA object that is part of the Orbix demo applications, you must first ensure that you've run the Orbix demo application in the Orbix environment, before running this Sun ONE sample application.
Initialization of multiple ORBs in this sample is avoided through the use of a singleton class. Regardless of the number of instances of the Servlet created by the Servlet 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 3 depicts the main components of this sample:
Figure 3    CORBA sample stucture
Setting Up the Environmentl
Setting up third party ORBs in Sun ONE Application Server describes how to setup and run the Orbix "SimpleObject" demo application in a standalone mode prior to following the instructions to run it with Sun ONE Application Server. Refer to the E2A Application Server Platform 5.1 Configuration document for more infomration.
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 web.xml CORBA Environment Settings Settings (Web Deployment descriptor)
After changing the environment settings , go to Compiling and Assembling the Application Using Ant Build Facility. 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 web.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 2 lists the environment settings required by the sample web application. These settings are available in the web.xml file, which is under the src/ directory of the sample application. If you are using the Ant Build facility to rebuild the sample application, then you can simply change the settings as they appear in the web.xml file and rebuild the application.
Modifying these settings in the web.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 web.xml file, do the following:
Edit <Sun-ONE-AS-install_dir>/samples/corba/servletsample/src/web.xml
Change the environment settings listed in Table 2 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-ONE-AS-install_dir>/samples/corba/servletsample/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 Facility
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-ONE-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-ONE-AS-install_dir>/samples/corba/servletsample/assemble/ear/.Rebuild the application by executing the asant command under the <Sun-ONE-AS-install_dir>/samples/corba/servletsample/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 ONE 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-servletsample.ear file is simple.
Go to the directory in which the newly assembled EAR file is located. For example: <Sun-ONE-AS-install_dir>/samples/corba/servletsample/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-ONE-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 ONE Admininstration Tool GUI provides an easy way of deploying applications to Sun ONE 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-ONE-AS-install_dir>/samples/corba/ejb/assemble/ear and open the corba-servletsample.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 asadmin 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: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 4    Servlet accessing backend CORBA server
Troubleshooting
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.
Servlet Initialization Failures
Servlet may issue a ServletException during the servlet's init() 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:
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.Invoking method on first object.
Caught exception: org.omg.CORBA.OBJ_ADAPTER: vmcid: SUN minor code: 202 completed: No (Minor code meaning not found)Server log:
[16/Apr/2002:19:13:15] INFO (10660): CorbaClientServlet: Invoking method on first object.
[16/Apr/2002:19:13:15] INFO (10660): creating connection to EndPoint: EndPoint
[IIOP_CLEAR_TEXT:129.158.228.203:38717:false]
[16/Apr/2002:19:13:15] INFO (10660): Caught exception: org.omg.CORBA.OBJ_ADAPTER: vmcid: SUN minor code: 202 completed: No (Minor code meaning not found)
NoClassDefFoundError
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.javax.servlet.ServletException: Servlet.init() for servlet CorbaClientServlet threw exception at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrappe r.java:935) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.j ava:653)
java.lang.NoClassDefFoundError: com/iona/corba/util/SystemExceptionDisplayHelper at samples.corba.common.OrbSingleton.(OrbSingleton.java:40) at samples.corba.common.OrbSingleton.getInstance(OrbSingleton.java:51)
[16/Apr/2002:18:29:27] INFO (10467): CorbaClientServlet: init
[16/Apr/2002:18:29:27] SEVERE (10467): StandardWrapperValve[CorbaClientServlet]: Allocate exception for
servlet CorbaClientServlet javax.servlet.ServletException: Servlet.init() for servlet CorbaClientServlet threw exception at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrappe r.java:935) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.j ava:653)
java.lang.NoClassDefFoundError: com/iona/corba/util/SystemExceptionDisplayHelper at samples.corba.common.OrbSingleton.<init>(OrbSingleton.java:40) at samples.corba.common.OrbSingleton.getInstance(OrbSingleton.java:51)
java.lang.NullPointerException
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.javax.servlet.ServletException: Servlet.init() for servlet CorbaClientServlet threw exception at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrappe r.java:935) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.j ava:653)
java.lang.NullPointerException at samples.corba.servletsample.CorbaClientServlet.init(CorbaClientServ let.java:66) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrappe r.java:916)
[16/Apr/2002:18:42:00] INFO (10486): CorbaClientServlet: init
[16/Apr/2002:18:42:00] SEVERE (10486): StandardWrapperValve[CorbaClientServlet]: Allocate exception for servlet
CorbaClientServlet javax.servlet.ServletException: Servlet.init() for servlet CorbaClientServlet threw exception at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrappe r.java:935) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.j ava:653)
java.lang.NullPointerException at samples.corba.servletsample.CorbaClientServlet.init(CorbaClientServ let.java:66) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrappe r.java:916)
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.Invoking method on first object.
Caught org.omg.CORBA.TRANSIENT exception.org.omg.CORBA.TRANSIENT: cannot establish binding vmcid:
0x49540000 minor code: 770 completed: No
Invoking method on second object.
Caught org.omg.CORBA.TRANSIENT exception.
[16/Apr/2002:18:21:43] INFO (10356): CorbaClientServlet: Invoking method on first object.
[16/Apr/2002:18:22:00] INFO (10356): Caught org.omg.CORBA.TRANSIENT exception.org.omg.CORBA.TRANSIENT:
cannot establish binding vmcid:
0x49540000 minor code: 783 completed: No
[16/Apr/2002:18:22:00] INFO (10356): CorbaClientServlet: Trying to reinitialize object refs.
[16/Apr/2002:18:22:00] INFO (10356): CorbaClientServlet: Invoking import_object() for first object
[16/Apr/2002:18:22:00] INFO (10356): CorbaClientServlet: Reading object reference from /space/sanju/install/orbix_2000/orbix_art/1.2/demos/simple1.ior
[16/Apr/2002:18:22:00] INFO (10356): Invoking import_object() for second object
[16/Apr/2002:18:22:00] INFO (10356): CorbaClientServlet: Reading object reference from /space/sanju/install/orbix_2000/orbix_art/1.2/demos/simple2.ior
[16/Apr/2002:18:22:00] INFO (10356): CorbaClientServlet: Invoking narrow on first object.
[16/Apr/2002:18:22:00] INFO (10356): CorbaClientServlet: Invoking narrow on second object.
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.Invoking method on first object.
Caught unexpected exception.java.lang.ClassCastException: com.sun.corba.ee.internal.corba.AnyImpl
[16/Apr/2002:18:12:30] INFO (10356): CorbaClientServlet: Invoking method on first object.
[16/Apr/2002:18:12:30] INFO (10356): Caught unexpected exception.java.lang.ClassCastException: com.sun.corba.ee.internal.corba.AnyImpl
Further Exploration
Using a Singleton for ORB Initialization describes how to implement the singleton to manage ORB initialization.EJB Accessing Backend CORBA Objects via IONA Orbix is a simple sample of an EJB accessing the same backend CORBA object as demonstrated in the servlet example.
Previous Contents Next
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated August 09, 2002