Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Java Client -OmniNames - Problem.

6 views
Skip to first unread message

JDS

unread,
Oct 1, 2001, 4:33:13 PM10/1/01
to
Hi:

I am trying to run a simple Hello World program with OmniNames as the
name server on NT. I can launch the naming service and bind the Server
to it. In the client, if I use the IOR for the HelloServant, I don't
have any problem:
--------------
ORB orb = ORB.init(args, null);
String ior = args[0];
org.omg.CORBA.Object obj = orb.string_to_object(ior);
HelloApp.Hello helloRef = HelloHelper.narrow(obj);


String hel = helloRef.sayHello();
System.out.println(hel);
--------------

However if I try to do the same by getting the IOR for the Root and
going down from there, I get errors while running as follows:

---------------
ORB orb = ORB.init(args, null);
String ior = args[0];
org.omg.CORBA.Object obj = orb.string_to_object(ior); // ERROR
NamingContext ncRef = NamingContextHelper.narrow(obj);
NameComponent nc = new NameComponent("Hello", "");
NameComponent path[] = {nc};
Hello helloRef = HelloHelper.narrow(ncRef.resolve(path));
String Hello = helloRef.sayHello();
System.out.println(Hello);

ERROR : java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
at com.sun.corba.se.internal.util.Utility.bytesToInt(Unknown
Source)
at com.sun.corba.se.internal.iiop.CDRInputStream.read_Object(Unknown
Sou
rce)
at com.sun.corba.se.internal.iiop.CDRInputStream.read_Object(Unknown
Sou
rce)
at com.sun.corba.se.internal.corba.ORB.string_to_object(Unknown
Source)
at HelloClient3.main(HelloClient3.java:18)
---------------

The IOR that I give at the commandline is the one I get when I start
omniNames using omniNames -start 10000.
Root Context is IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f
4e616d696e67436f6e746578744578743a312e300000010000000000000027000000010100000e00
00003139382e33302e39362e3231300010270b0000004e616d6553657276696365

Questions:
Q1. Why do I get the above errors?
Q2. How can I get my Java Client to always get the proper IOR for the
Naming Service when I start it up (using the system environment)
Q3. If I am able to get the client to get the root object properly,
can I replace the orb.string_to_object() call by:
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");


Thanks,

JDS.
j...@iti-oh.com

Duncan Grisby

unread,
Oct 2, 2001, 5:32:33 AM10/2/01
to
In article <6b2d6822.01100...@posting.google.com>,
JDS <j...@iti-oh.com> wrote:

[...]
>ERROR : java.lang.ArrayIndexOutOfBoundsException
>java.lang.ArrayIndexOutOfBoundsException

[...]


>Q1. Why do I get the above errors?

The JDK 1.3 ORB has a serious bug that means it cannot cope with the
object key in omniNames' root context. The bug only happens if the
Naming service is running on the same machine as the client.

It's supposedly fixed in JDK 1.4. See Sun's bug page:

http://developer.java.sun.com/developer/bugParade/bugs/4351366.html

>Q2. How can I get my Java Client to always get the proper IOR for the
>Naming Service when I start it up (using the system environment)
>Q3. If I am able to get the client to get the root object properly,
>can I replace the orb.string_to_object() call by:
> org.omg.CORBA.Object objRef =
> orb.resolve_initial_references("NameService");

In theory you can, using the proprietary Java ORBInitialHost/
ORBInitialPort configuration, which omniORB also supports.
Unfortunately, I think that fails due to the array index bug too.

By far your best bet is to use one of the decent Java ORBs that
supports the Interoperable Naming Service.

Cheers,

Duncan.

--
-- Duncan Grisby \ Research Engineer --
-- AT&T Laboratories Cambridge --
-- http://www.uk.research.att.com/~dpg1 --

JDS

unread,
Oct 2, 2001, 12:02:06 PM10/2/01
to
Hi Duncan:

I updated to JDK1.4 (Beta Version) and that got rid of this problem.
Not surprisingly, I now have another problem.

I can get the following Python Server and Java Client to talk to each
other and do their thing. I pass in the IOR which is output when the
naming service is launched as input to the Client.
=================================================================
#Python Server:
import sys
from omniORB import CORBA, PortableServer
import CosNaming, HelloApp, HelloApp__POA

class HelloServant (HelloApp__POA.Hello):
def sayHello(self):
print "Serving..."
return "Hello World\n"

orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
poa = orb.resolve_initial_references("RootPOA")

ei = HelloServant()
eo = ei._this()
obj = orb.resolve_initial_references("NameService");
rootContext = obj._narrow(CosNaming.NamingContext)

if rootContext is None:
print "Failed to narrow root naming service context"
sys.exit(1)

name = [CosNaming.NameComponent("Hello", "")]

# Bind the HelloApp object to the test context
name = [CosNaming.NameComponent("Hello", "")]
try:
rootContext.bind(name, eo)
print "New Hello object bound"

except CosNaming.NamingContext.AlreadyBound:
rootContext.rebind(name, eo)
print "Hello binding already existed -- rebound"

#print orb.object_to_string(eo)
poaManager = poa._get_the_POAManager()
poaManager.activate()
orb.run()
----------------------------------------------
// Java Client
import HelloApp.*; // The package containing our stubs.
import org.omg.CosNaming.*; // HelloClient will use the naming
service.
import org.omg.CORBA.*; // All CORBA applications need these
// classes.

public class HelloClient3
{
public static void main(String args[])
{
try
{
//CosPropertyService.Properties prop = new Properties();
//prop.setProperty("ORBInitRef.NameService","IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f6e746578744578743a312e300000010000000000000027000000010100000e0000003139382e33302e39362e3231300010270b0000004e616d6553657276696365");
ORB orb = ORB.init(args, null );


String ior = args[0];
org.omg.CORBA.Object obj = orb.string_to_object(ior);

//org.omg.CORBA.Object obj =
orb.resolve_initial_references("NameService");

NamingContext ncRef = NamingContextHelper.narrow(obj);

NameComponent nc = new NameComponent("Hello", "");
NameComponent path[] = {nc};
Hello helloRef = HelloHelper.narrow(ncRef.resolve(path));

// Call the Hello server object and print results


String Hello = helloRef.sayHello();
System.out.println(Hello);

//HelloApp.Hello helloRef = HelloHelper.narrow(obj);
//String hel = helloRef.sayHello();
//System.out.println(hel);
}
catch(Exception e)
{
System.out.println("ERROR : " + e);
e.printStackTrace(System.out);
}
}
}
===================================================================
Now I tried to resolve the root context by putting the following code
and get errors as follows:

-----------------------
HelloClient4.java
..
..
try
{


ORB orb = ORB.init(args, null);

org.omg.CORBA.Object obj =
orb.resolve_initial_references("NameService");
.....

----------------------
C:\Sandbox\fiper_p2\ws1\test1>java HelloClient4 -ORBInitialPort 10000
ERROR : org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 208
completed: May
be
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 208 completed:
Maybe
at com.sun.corba.se.internal.iiop.IIOPConnection.purge_calls(IIOPConnect
ion.java:441)
at com.sun.corba.se.internal.iiop.MessageMediator.handleInput(MessageMed
iator.java:162)
at com.sun.corba.se.internal.iiop.messages.MessageBase.callback(MessageB
ase.java:715)
at com.sun.corba.se.internal.iiop.MessageMediator.processRequest(Message
Mediator.java:145)
at com.sun.corba.se.internal.iiop.IIOPConnection.processInput(IIOPConnec
tion.java:339)
at com.sun.corba.se.internal.iiop.ReaderThread.run(ReaderThread.java:63)


The naming service gets a message and gives the following messages:
----------
omniORB: throw omniConnectionBroken (minor 0) from giopServer.cc:400
omniORB: tcpSocketStrand::~Strand() close socket no. 224
----------

Question: Why is the Client not able to get the Root Context from the
naming service when it can find the naming service. It was able to get
the required context when I used the IOR for the naming service. I
also tried specifying both the hostname and the hostport, but got the
same errors.

Thanks,

jds.

Duncan Grisby <dgr...@uk.research.att.com> wrote in message news:<9pc1jh$5hg$1...@pea.uk.research.att.com>...

Duncan Grisby

unread,
Oct 4, 2001, 8:11:04 AM10/4/01
to

>omniORB: throw omniConnectionBroken (minor 0) from giopServer.cc:400
>omniORB: tcpSocketStrand::~Strand() close socket no. 224

That just shows that the Java ORB closed the connection. It's not an
error in and of itself.

>----------
>
>Question: Why is the Client not able to get the Root Context from the
>naming service when it can find the naming service. It was able to get
>the required context when I used the IOR for the naming service. I
>also tried specifying both the hostname and the hostport, but got the
>same errors.

I don't know what's going wrong. Try running omniNames with
-ORBtraceLevel 30. That should show what, if any, traffic is passing
between Java and omniNames.

Do the omniORB Naming service examples work? If not, there's
something wrong with your omniORB set-up. If they do work, the problem
probably lays with Java.

JDS

unread,
Oct 18, 2001, 5:31:32 PM10/18/01
to
Hi:

If I hard-code the IOR string for the naming service and use
string_to_object() to get the reference to the naming service instead
of using resolve_initial_references(..), it works. That does the job
for now, but I still don't know why resolve_initial_references() gives
this error.

Jaidev.

Duncan Grisby <dgr...@uk.research.att.com> wrote in message news:<9phjko$qi9$1...@pea.uk.research.att.com>...

0 new messages