• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception when start rmi server

 
HK Stojkovic
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I get following exception when start my rmi server. My hostname is 10978a and ip address is 192.168.142.250 (in my working place network)
java.rmi.ConnectException: Connection refused to host: 192.168.142.250; nested exception is:
java.net.ConnectException: Connection refused: connect
I start rmiregistry on port 6666 and start rmi server by following command
java -Djava.rmi.server.codebase=http://10978a:6666/ -Djava.security.policy=/resin-2.0.5/doc/policy com.server.MyServerImpl
It works if I change to use localhost instead of my hostname. I've added entry in .java.policy
grant {
permission java.lang.RuntimePermission "stopThread";
/*permission java.net.SocketPermission "localhost:1024-", "listen";*/
permission java.net.SocketPermission "10978a","accept,connect,resolve";
permission java.util.PropertyPermission "java.version", "read";
permission java.util.PropertyPermission "java.vendor", "read";
permission java.util.PropertyPermission "java.vendor.url", "read";
permission java.util.PropertyPermission "java.class.version", "read";
permission java.util.PropertyPermission "os.name", "read";
permission java.util.PropertyPermission "os.version", "read";
permission java.util.PropertyPermission "os.arch", "read";
permission java.util.PropertyPermission "file.separator", "read";
permission java.util.PropertyPermission "path.separator", "read";
permission java.util.PropertyPermission "line.separator", "read";
permission java.util.PropertyPermission "java.specification.version", "read";
permission java.util.PropertyPermission "java.specification.vendor", "read";
permission java.util.PropertyPermission "java.specification.name", "read";
permission java.util.PropertyPermission "java.vm.specification.version", "read";
permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
permission java.util.PropertyPermission "java.vm.specification.name", "read";
permission java.util.PropertyPermission "java.vm.version", "read";
permission java.util.PropertyPermission "java.vm.vendor", "read";
permission java.util.PropertyPermission "java.vm.name", "read";
};
grant {
permission java.security.AllPermission;
};
So could anyone provide me any solution? Thanks.
ST
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this example, you are pointing java.rmi.server.codebase to your registry, which will not work.
When a stub is exported to the registry, it is encoded by the server JVM with a location that the registry can use to retrieve the class definition that was used to make the stub object. The client process can get a stub from the registry, but the registry cannot serve the class definition as well.
The likely source for the class definition is the same place that the registry got it from, although this is not strictly required.
This is the part of the exercise that always works for people on one machine because the file:/// protocol will always work. Once you go to remote machines, however, you must provide some way for the client to retrieve the class definition over the wire. A very simple web server will do the trick.
 
HK Stojkovic
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
Thanks for you comment.
But I don't completely get your message. Does the exception complaint about the failure of connection thru port 6666 to the registry? If the codebase setting is wrong and lead to missing class definition, the excepton should be java.lang.ClassNotFoundException.
ST
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, in a word, no, that's not what should happen.
ClassNotFoundExceptions occur when a class loader is unable to find a definition for a class using the string name of the class. In this case, your connection to the registry is being refused because you've used to wrong request protocol. The class loader on the client side never gets a chance to call the class definition because you haven't connected properly yet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!