my dog learned polymorphism
The moose likes EJB and other Java EE Technologies and the fly likes question about rmi registry Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply locked New topic
Author

question about rmi registry

zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 403
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
Edy Yu
Ranch Hand

Joined: Nov 21, 2000
Posts: 264
because you have to set the permission of the port you want to use.
You can use the permission tool packed to JDK or edit your own policy file.
Below is a very simple policy file. It simple grant you everything.
grant {
permission java.security.AllPermission;
};
and when you run the server,
use -Djava.security.policy option


<i><br />Sun Certified Programmer for Java 2 Platform (SCJP)<br />Sun Certified Developer for Java 2 Platform (SCJD)<br />Sun Certified Web Component Developer for Java2 Platform, Enterprise Edition (SCWCD)<br />Sun Certified Business Component Developer for Java2 Platform, Enterprise Edition (SCBCD)<br />Sun Certified Enterprise Architect for J2EE (SCEA)<br />IBM Certified Enterprise Developer, WebSphere Studio V5.0<br /></i>
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
zb,
Do not cross post the same message in multiple forums!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: question about rmi registry
 
Similar Threads
RMI client server don't work on ipv6 machines
question about rmi registry
Access Control Exception
RMI pass by value or by reference ?
question about rmi registry