question about rmi registry
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   zhebin_cong
Posted On:   Sunday, January 20, 2002 08:28 AM

hello i write a simple interface "Hello.java",i want to call it by rmi,after "javac","rmic","rmiregistry",i want to start "RMIServer.class" that is used to register in the server,see my code: ================================================== public class RMIServer{ private static final int PORT=1099; private static final String HOSTNAME="127.0.0.1"; public RMIServer() throws RemoteException, MalformedURLException, NotBoundException{ LocateRegistry.createRegistry(PORT); System.out.println("registry:"+HOSTNAME+" in "+(Integer.toStr   More>>

hello
i write a simple interface "Hello.java",i want to call it by rmi,after "javac","rmic","rmiregistry",i want to start "RMIServer.class" that is used to register in the server,see my code:

==================================================
public
class RMIServer{

private static final int PORT=1099;

private static final String
HOSTNAME="127.0.0.1";


public RMIServer()

throws RemoteException,

MalformedURLException,

NotBoundException{


LocateRegistry.createRegistry(PORT);

System.out.println("registry:"+HOSTNAME+" in "+(Integer.toString(PORT)));

Hello h=new HelloImpl();

System.out.println("remote object has be created");

String urlString="//"+HOSTNAME+":"+Integer.toString(PORT)+"/HelloService";
Naming.rebind(urlString,h);

System.out.println("binding finished");

}


public

static

void

main(String argv[]){

System.setSecurityManager(new RMISecurityManager());


try{

RMIServer rs=new RMIServer();

}catch(Exception e){

System.err.println(e);

}

}

=================================================


i type"java RMIServer",it tell me:


==================================================
java.rmi.server.ExportException: Port already in use: 1099; nested exception is:


java.net.BindException: Address already in use: JVM_Bind

==================================================


then i modify the port number to "10002",it said:


==================================================

registry:127.0.0.1 in 10002
remote object has be created

java.security.AccessControlException: access denied (java.net.SocketPermission
127.0.0.1:10002 connect,resolve)

==================================================


who can tell me why?

thanks alot
.

   <<Less

Re: question about rmi registry

Posted By:   Anonymous  
Posted On:   Monday, January 21, 2002 11:15 AM

If you use the RMI Security Manager, use a policy file to allow the connection. (Look at java.sun.com for examples)


If you just don't set the security manager, your program should work fine (but the RMI dynamic classloading feature will be disabled, as this requires a security manager)






Regards,



G√ľnther.

http://www.javacoding.net

Re: question about rmi registry

Posted By:   Gautam_Shah  
Posted On:   Sunday, January 20, 2002 10:23 PM

i think this is due to security restrictions imposed by rm security manager. try to write a policy file in which give the permission to open the ports on the machiene. and after that every thing will be fine. ( as far as connection is concerned) I Hope.
About | Sitemap | Contact