faliure to register a remote object with the rmiregistry
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Adi_peretz
Posted On:   Friday, April 5, 2002 11:09 AM

hello i have an rmi object that i cant register with the rmi registry i'm using the LocateRegistry.getRegistry() method and it gets the registry but when i use the bind() method from that Registry object i get a RemoteException i have tired everything the odd thing is when i try to register another rmi object it worked but it dosent seem to work with this object i alos tryed to use the Naming.rebind() method that also didnt work i dont know whats wrong if there is anyone that can help thank you very much here is the code: this is the rmi object implementation import java.rmi.Remote;//used to mark an interface as a Remote interface import java.rmi.RemoteException   More>>

hello
i have an rmi object that i cant register with the rmi registry i'm using the LocateRegistry.getRegistry() method
and it gets the registry but when i use the bind() method from that Registry object i get a RemoteException
i have tired everything the odd thing is when i try to register another rmi object it worked
but it dosent seem to work with this object
i alos tryed to use the Naming.rebind() method that also didnt work i dont know whats wrong if there is anyone that can help thank you very much
here is the code:
this is the rmi object implementation

			


import java.rmi.Remote;//used to mark an interface as a Remote interface
import java.rmi.RemoteException;//every method that is going to be a Remote method needs to declare it throws this Exception
import java.rmi.server.UnicastRemoteObject;//used for creatin a stub and skeleton objects

interface ThisOrThatServer extends Remote

{
public String doThis(String todo) throws RemoteException;
public String doThat(String todo) throws RemoteException;
}

public class ThisOrThatServerImpl implements ThisOrThatServer
{
private String serverName;
public ThisOrThatServerImpl(String serverName) throws RemoteException{this.serverName=serverName;}

//Remote methods
public String doThis(String todo) throws RemoteException
{
return doSomething("this",todo);
}
public String doThat(String todo) throws RemoteException
{
return doSomething("this",todo);
}

//Non-remote methods
private String doSomething(String what,String todo)
{
String result="Did" +what+ "to" +todo+".";
return result;
}
}



and here is the register code
			


import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.AlreadyBoundException;
import java.rmi.AccessException;
import java.net.MalformedURLException;

public class RegThisOrThatServerImpl
{
public static void main(String args[])
{




try {
ThisOrThatServerImpl server=new ThisOrThatServerImpl("TTServer");
System.out.println("object was created");
//Naming.rebind("TTServer",server);
LocateRegistry.createRegistry(8080);
Registry locateRegistry=LocateRegistry.getRegistry();
if(locateRegistry!=null);
{
System.out.println("got registry");
}
String list[]=locateRegistry.list();
for(int i=0;i
{
System.out.println(list[i]);
}

locateRegistry.rebind("TTServer",server);
}

catch(RemoteException re)
{
System.out.println("RemoteException");
}

//catch(AlreadyBoundException abe)
//{
//System.out.println("AlreadyBoundException");
//}
//catch(MalformedURLException ac)
//{
//System.out.println("MalformedURLException");
//}
}
}


   <<Less

Re: faliure to register a remote object with the rmiregistry

Posted By:   pradeep_kumar  
Posted On:   Tuesday, April 16, 2002 09:52 PM

hi adi
put createRegistry method before binding remote object
naming.rebind
About | Sitemap | Contact