[omniORB] Contacting the omniORB3 name server from Java2 CORB A

Bang, Steinar Steinar.bang@tandbergtv.com
Mon, 26 Nov 2001 09:10:56 +0100


I wrote last Friday:

> Platform: Intel PIII, RedHat linux 7.2, gcc 2.96
> 	omniORB 3.0.2, Sun JDK 1.3.1
> 
> I am trying to contact the omniORB3 name server from
> the built-in ORB of Java2.

In section 4.3.2, on page 53 of the PDF file for "The
omniORB version 3.0 User's Guide", it says
"To make it easy to use omniNames with corbaname URIs,
 it now starts with the default port of 2809, and an
 object key of 'NameService' for the root naming context."

Again trying blindly, I'm using 
         props.setProperty("org.omg.CORBA.ORBInitialHost",
                           "localhost");
         props.setProperty("org.omg.CORBA.ORBInitialPort",
                           "2809");
to set up where to look for the name service.

This at least gives me java.lang.ArrayIndexOutOfBoundsException,
instead of an org.omg.CORBA_COMM_FAILURE exception.

Here's the stack trace:
java.lang.ArrayIndexOutOfBoundsException
	at
com.sun.corba.se.internal.util.Utility.bytesToInt(Utility.java:1071)
	at
com.sun.corba.se.internal.iiop.CDRInputStream.read_Object(CDRInputStream.jav
a:606)
	at
com.sun.corba.se.internal.iiop.CDRInputStream.read_Object(CDRInputStream.jav
a:578)
	at
com.sun.corba.se.internal.corba.InitialNamingClient.resolve(InitialNamingCli
ent.java:209)
	at
com.sun.corba.se.internal.corba.InitialNamingClient.cachedInitialReferences(
InitialNamingClient.java:265)
	at
com.sun.corba.se.internal.corba.InitialNamingClient.resolve_initial_referenc
es(InitialNamingClient.java:188)
	at
com.sun.corba.se.internal.corba.ORB.resolve_initial_references(ORB.java:1461
)
	at ListNames.main(ListNames.java:34)

ListNames.java:34, contains a call to
org.omg.CORBA.ORB.resolve_initial_references().
I'm putting the entire source of ListNames.java at
the end of this message.

As always, all hints, and guesses are appreciated.

Thanx!


- Steinar

---ListNames.java -----------------------
import java.io.*;
import java.util.*;
import org.omg.CosNaming.*;

public class ListNames {

   void useJacORB()
   {
      // Use JacORB instead of the Java2 ORB
      Properties props = new Properties();
      System.setProperty("org.omg.CORBA.ORBClass",
                         "org.jacorb.orb.ORB");
      System.setProperty("org.omg.CORBA.ORBSingletonClass",
                         "org.jacorb.orb.ORBSingleton");
   }

   public static void main(String[] args)
   {
      //useJacORB();
      Properties props = new Properties();
      boolean useCorbaName = false;
      if (useCorbaName) {
         props.setProperty("org.omg.CORBA.ORBInitRef.NameService",
                           "corbaname::localhost:2809");
      } else {
         props.setProperty("org.omg.CORBA.ORBInitialHost",
                           "localhost");
         props.setProperty("org.omg.CORBA.ORBInitialPort",
                           "2809");
      }

      try {
         org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,props);
         org.omg.CORBA.Object tmp =
            orb.resolve_initial_references("NameService");
         NamingContext rootContext = NamingContextHelper.narrow(tmp);
         printNCRecursive(rootContext, "", 100);
      } catch (Exception e) {
         e.printStackTrace();
      }
   }

   /*!
     recursive function to print out the naming contexts found.
   */
   static void printNCRecursive(NamingContext ctx, String indent, int
howMany)
   {
      if (ctx == null) {
         return;
      }

      try {
         BindingListHolder bl = new BindingListHolder();
         BindingIteratorHolder bi = new BindingIteratorHolder();
         ctx.list(howMany, bl, bi);
         for (int i=0; i<bl.value.length; ++i) {
            NameComponent[] nc = bl.value[i].binding_name;
            System.out.print(indent);
            for (int j=0; j<nc.length; ++j) {
               System.out.print(nc[j].id);
               System.out.print(".");
            }
            System.out.println();
            org.omg.CORBA.Object tmp =  ctx.resolve(nc);
            NamingContext tmpCtx = null;
            try {
               tmpCtx = NamingContextHelper.narrow(tmp);
            } catch (Exception e) {}
            printNCRecursive(tmpCtx, indent + "  ", howMany);
         }
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}











































This email, its content and any attachments is PRIVATE AND CONFIDENTIAL to
TANDBERG Television. If received in error please notify the sender and
destroy the original message and attachments.