How Do I Deploy Enterprise JavaBeans to iPlanet?

An Oracle JDeveloper How To Document
July 26, 2002

Content

 

 

Introduction

This document describes in detail the requirements and steps to deploy Enterprise JavaBeans to the Sun ONE/iPlanet Application Server.

This document was written for Oracle9i JDeveloper 9.0.2 and Sun iPlanet Application Server 6.5 Enterprise Edition on Windows 2000, although other versions of Oracle9i JDeveloper and/or iPlanet Application Server should behave the same.

 

Starting iPlanet

On Windows start iPlanet using the Services Control Panel applet inside of the Administrative Tools folder.

On UNIX, please consult the iPlanet Administration Documentation.

 

Creating a Simple EJB

Create a New Stateless Session Bean.  This is a choice under the Enterprise JavaBeans category from the New Gallery.  In the Enterprise JavaBean Wizard, click Next to accept all defaults, then click Finish. In the EJB Class Editor, select the Fields tab, and add a new field named info. This creates accessor methods on the EJB that can be invoked in the EJB test application.

 

Creating a JDK Definition for the JDK Used by iPlanet

To use RMI-IIOP with iPlanet, you need to use the iPlanet Object Request Broker (ORB). This ORB is pre-installed in the Java Runtime Environment (JRE) included with iPlanet in the directory \iPlanet\ias6\ias\usr\java. If you are using Oracle9i JDeveloper on a different machine than the iPlanet Application Server you must either copy this JRE to the machine with JDeveloper, or follow the manual installation steps for the iPlanet ORB from Chapter 10 of the iPlanet Application Server Developers Guide.

Follow these steps to create a JDK definition for JDeveloper to use the JRE from iPlanet.

  1. From the main menu, choose Project > Project Settings...
  2. In the tree, select Libraries
  3. On the right of the J2SE Version combo box, click Define
  4. For the J2SE Name, enter iPlanet JDK 1.3.1
  5. Click Browse and browse to the java.exe bundled with iPlanet, this is located in the directory \iPlanet\ias6\ias\usr\java\bin\java.exe
  6. Click OK

 

Creating a Library in JDeveloper for the iPlanet Client JAR files

Oracle9i JDeveloper needs a library definition which contains the client side JAR files required to test an Enterprise JavaBean deployed inside iPlanet. 

Here are the JAR files required for the JDeveloper library:

  • \iPlanet\ias6\ias\classes\java\iasclient.jar
  • \iPlanet\ias6\ias\classes\java\javax.jar

Create a new Library in JDeveloper, name it iPlanet EJB Client and add both of these JAR files to the library.

Here is an example of the library definition as created with JDeveloper:

Library page showing all the client side JAR files required to test an EJB deployed to iPlanet

 

 

Creating the Test Client for iPlanet

Create a test client for your EJB with the Create Sample Java Client context menu item from the EJB node in the Navigator. Choose Connect to Remote App Server in the Sample EJB Java Client Details dialog, and ignore the values of the J2EE Application Name and Oracle9iAS Connection Name. Click OK.

 

You must modify the default EJB test client to use the JNDI properties for iPlanet.

Here are the JNDI properties that iPlanet requires:

 env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
 env.put(Context.PROVIDER_URL, "iiop://localhost:9010");

Since iPlanet uses RMI-IIOP, instead of casting the result of Context.lookup use the method, PortableRemoteObject.narrow. It is good practice to use PortableRemoteObject.narrow as it is required in EJB 2.0.

Add code to invoke the setInfo and getInfo methods previously added by the EJB Class Designer. Here is an example of the test application modified to invoke these methods:

 Hashtable env = new Hashtable(); 
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:9010");
Context ctx = new InitialContext(env);
Object objref = ctx.lookup("ejb/MySessionEJB");
MySessionEJBHome mySessionEJBHome = (MySessionEJBHome) PortableRemoteObject.narrow( objref, MySessionEJBHome.class );
// Use one of the create() methods below to create a new instance
MySessionEJB mySessionEJB = mySessionEJBHome.create();
// Call any of the Remote methods below to access the EJB mySessionEJB.setInfo("Hello World");
System.out.println( mySessionEJB.getInfo() );

 

Deploying the EJB JAR File to iPlanet

Deploying the EJB JAR file from JDeveloper to iPlanet is two distinct procedures. The first creates the EAR file from within JDeveloper. The second takes the EAR file, adds iPlanet specific information, creates client RMI-IIOP stubs, and deploys it to the Application Server.

 

Use these steps to create the EJB EAR file.

  1. From the main menu, choose File > New
  2. In the New Gallery, choose the Deployment Profiles category.
  3. Select EJB JAR File - J2EE EJB Module
  4. Click OK
  5. Leave the name the default ejb1.deploy and click Save.
  6. On the J2EE EJB Module Deployment Profile Settings, click OK (no changes are required)
  7. In the Navigator, right-click the ejb1.deploy node
  8. Choose Deploy to EAR file from the context menu

 

Use these steps to deploy the EJB EAR file.

  1. Invoke the iPlanet iAS Deployment Tool
  2. Open the EAR file created in the last section
  3. On the warning about "Non IAS Modules will be migrated to IAS", click OK
  4. Save the EAR file
  5. Re-open the EAR file
  6. On the warning about "Non IAS Modules will be migrated to IAS", click OK
  7. In the navigator, select the tab ComponentView
  8. In the navigator, select MySessionEJB
  9. From the main menu, choose Edit > Edit Descriptor
  10. On the General tab, check Enable RMI-IIOP
  11. From the main menu, choose Edit > Save Descriptor
  12. Close the editor.
  13. In the main menu, select ejb1 (which is the first item under J2EE Applications)
  14. From the main menu, choose File > Deploy
  15. On the confirmation dialog, click Yes
  16. You can look at the directory containing the EAR file at this point, and it should contain a file named ejb1-RmiCorba.jar. This file contains the RMI-IIOP client stubs for your EJB Session Bean.
  17. On the Deploy dialog, select the server from the list. (If no server is registered, register it now by clicking Register)
  18. Click Deploy

If there are any errors during deployment, they will be displayed in the Message window.

 

Creating a Library in JDeveloper for the EJB Client Stubs

Oracle9i JDeveloper needs a library definition containing the client side RMI-IIOP stubs which were generated as part of deployment to iPlanet.  This archive is located in the same directory as the ejb1.ear file and is named ejb1-RmiCorba.jar.

  1. Create a new Library in JDeveloper named MySessionEJB Stubs
  2. Add the file ejb1-RmiCorba.jar to the library

 

Testing the EJB in iPlanet

  1. Edit your project properties
    1. Remove the Oracle9i iAS library
    2. Add the iPlanet EJB Client library
    3. Add the MySessionEJB Stubs library
    4. Change the J2SE to iPlanet JDK 1.3.1
  2. Run the test client
  3. Verify that "Hello World" is displayed in the JDeveloper Message Log

 

References

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy