Reputation: 450
I got a problem on RMI:
My RMI-Client trys to get the registry of 192.168.1.37
Registry registry = LocateRegistry.getRegistry("192.168.1.37",1099);
String[] s = registry.list();
for( String obj : s ) {
System.out.println(" " + obj);
}
IMaster master = (IMaster) registry.lookup ("rmi://192.168.1.37:1099/Master");
My RMI-Server looks like this:
Registry registry = LocateRegistry.getRegistry();
IMaster m = new Master(3, 3);
registry.rebind ("Master", m);
System.out.println ("Master Server is ready.");
The registry-List [String[] s = registry.list();] knows the "Master"-binding. That means: There is no problem on the network and the registry exists. Also the object is already exported. (I use a eclipse-plugin for RMI).
But at the lookup-line of the client i got a exception:
java.rmi.NotBoundException: rmi://192.168.1.37:1099/Master
at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:136)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at philosoper.client.ClientServer.main(ClientServer.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at net.genady.rmi.logger.Runner.main(Runner.java:137)
Does any one knows how to fix this? :) Thx
Upvotes: 0
Views: 3624
Reputation: 450
The Server didn't know his own IP. So you have to start it by telling him the ip of your server.
I use the Eclipse-Plugin: genady
So on the server in eclipse: Click on "Run Configurations..." -> "RMI VM Properties" and add that IP to "java.rmi.server.hostname"
And:
IMaster master = (IMaster) registry.lookup ("Master");
Thats all. Thx for your help :)
Upvotes: 0
Reputation: 7415
Try changing
IMaster master = (IMaster) registry.lookup ("rmi://192.168.1.37:1099/Master");
to
IMaster master = (IMaster) registry.lookup ("Master");
Upvotes: 2