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

RMI and the registry

2 views
Skip to first unread message

Uli Waibel

unread,
Feb 18, 2002, 8:10:21 AM2/18/02
to
Hi to all,

I have a problem with RMI and the registry.

I have two seperate processes, each is trying to locate a registry. If
none was found, they create one (in fact only the first one create the
registry)
Now each process bind his service to the registry.
For both processes all seems to be o.k.

If i start now the client and use a remote method of process 1 (the
first who created the registry and created his interface to it)
everything works fine.
If I try to call a method of the second process (from the same client)
I get a notBoundException for the second service.


My question: Is it possible to use a single registry from within two
different processes ? or do I have to use a registry for each of them
?

Any help is really apreciated.


<<<<< code of locating, creating and binding to a registry
>>>>>>>>>>>>

int rmiPort=1099;
String rmiHost="localhost";
String rmiService;
// temp is configurable
rmiService = "//"+rmiHost+":"+rmiPort+"/"+temp

try
{
reg = LocateRegistry.getRegistry(rmiHost, rmiPort);
reg.rebind(this.rmiService, this);
}
catch( RemoteException e )
{
LocateRegistry.createRegistry( rmiPort ); //default port
java.rmi.Naming.rebind(this.rmiService, this );
}

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<<<<<<<<<<<< client code >>>>>>>>>>>>>>>>>>
// get Version from Process 1

public String getVersionQS() throws
MalformedURLException,RemoteException,NotBoundException
{
IQuoteSelectorRMI rmi =
(IQuoteSelectorRMI)java.rmi.Naming.lookup("rmi://"+host+"/QuoteSelector");
return rmi.getVersion();
}

// get Version from Process 1

public String getVersionTG() throws
MalformedURLException,RemoteException,NotBoundException
{
IQuoteSelectorRMI rmi =
(IQuoteSelectorRMI)java.rmi.Naming.lookup("rmi://"+host+"/Generator");
return rmi.getVersion();
}
<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


<<<<<<<<<<< the exception on client side >>>>>>>>>>>>>>>>>>><
java.rmi.NotBoundException: QuoteSelector
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:354)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:84)
at de.boersestuttgart.taxen.taxencontroller.RmiConTaxGen.versionQS(RmiConTaxGen.java:139)
at de.boersestuttgart.taxen.taxencontroller.TaxenCtrl.processInput(TaxenCtrl.java:131)
at de.boersestuttgart.taxen.taxencontroller.TaxenCtrl.main(TaxenCtrl.java:50)

Uli Waibel

Esmond Pitt

unread,
Feb 18, 2002, 9:48:25 PM2/18/02
to
The parameter to Naming.rebind is an RMI URL. However the parameter to
Registry.rebind is *not* a URL, it is just the name part. So whichever
process creates the registry registers itself under the wrong name and
won't be found by the other process.

EJP

Uli Waibel

unread,
Feb 19, 2002, 5:58:56 AM2/19/02
to
Thanks a lot, now it works

Uli

Esmond Pitt <esmon...@bigpond.com> wrote in message news:<3C71BD4C...@bigpond.com>...

0 new messages