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

RMI Registry

0 views
Skip to first unread message

Uli Waibel

unread,
Feb 15, 2002, 9:04:18 AM2/15/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

0 new messages