Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

question about rmi registry

 
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
If you're starting the registry by doing rmiregisrty on a command line first (as many examples tell you to do) this is using the 1099 port such that you application cannot bind to the same port (or after running you server for the first time, it doesn't release the port). Check to see if the registry is already running. As well, after you get this staightened out, you'll probebly need to pass a securtiy policy file to you server when you start it. A basic policy file is
mysecurity.policy
grant {
// Allow everything for now
permission java.security.AllPermission;
};
then point the server to this file when you start the server
java -Djava.security.policy=mysecurity.policy MyServerClass
As well, you might want to bind the server using the protocol "rmi://" + HOSTNAME in you servers url.
Hope this helps.
Sean
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
zb,
Do NOT cross post the same question in multiple forums. Pick the best forum and post to it.
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
    Bookmark Topic Watch Topic
  • New Topic