The client receives the server callbacks sucessfully - but the client stub has to be available at both the client and server. Is there some way to make this work with the client stub available only as part of the server process?
Pass the exported remote object: InterfaceName in = (InterfaceName)UnicastRemoteObject.exportObject(this); to the server as a parameter in your remote method call: server.helloBigBoy(in, other fields);
Now the server can call your client without going to the registry.
We pass in the 'this' reference to registerfornotification method of the server(which is in line with what you said).
The registerforNotification simply adds the interface to a vector ,to be called back on later.
However,if we remove the client stub from the server classpath ,we get the following exception:
Jan 11, 2007 11:21:26 AM sun.rmi.server.LoaderHandler loadClass FINE: RMI TCP Connection(2)-184.108.40.206: name = "com.ibm.applet.PackagedApplet_ Stub", codebase = "http://<machine-name>:8888/appletRMI/applet/remotermi.jar ht tp://<machine-name>:8888/appletRMI/" Jan 11, 2007 11:21:26 AM sun.rmi.server.LoaderHandler loadClass FINER: RMI TCP Connection(2)-220.127.116.11: (thread context class loader: sun.misc.Launcher$AppClassLoader@133056f) Jan 11, 2007 11:21:26 AM sun.rmi.server.LoaderHandler loadClass FINE: RMI TCP Connection(2)-18.104.22.168: class com.ibm.applet.PackagedApplet_Stub" not found via thread context class loader (no security manager: codebase disabled) java.lang.ClassNotFoundException: com.ibm.applet.PackagedApplet_Stub at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) ...... .......
What is the way out of this - apart from the alternative of adding the client stub in the server classpath.
You can't pass "this" as a remote object. This is why you now need the stub in the classpath.
Get the remote object back from the export. Save it somewhere. Pass that remote object to the server, not "this".
InterfaceName in = (InterfaceName)UnicastRemoteObject.exportObject(this);
Pass "in" to the server, not "this".
Joined: Mar 09, 2006
I saved the exportobject into an interface and passed it;I was getting the same problem. However after configuring the Security Manager and the policy file,I can callback on the client without requiring the client stub on the server.