Eclipse RCP & RMI
Hi,
I might be considered a noob with these two technologies and I have a problem using RMI with my eclipse RCP app.
Simple RMI server and client works fine, however if use eclipse rcp as the client, it hangs forever while "lookup".
Simple Server Code:
System.setSecurityManager(new RMISecurityManager());
Registry registry = LocateRegistry.getRegistry("localhost", 1099);
HelloImpl obj =new HelloImpl();
registry.rebind("HelloServer", obj);
Simple RCP Client Code: (executed in a job scheduled)
System.setSecurityManager(new MySecurityManager());
Registry registry = LocateRegistry.getRegistry("localhost", 1099);
Hello obj = (Hello) registry.lookup("HelloServer");//hangs here
String message = obj.sayHello();
MySecurityManager:
publicclass MySecurityManagerextends SecurityManager{
public MySecurityManager(){}
publicvoid checkPermission(){}
publicvoid checkPermission(Permission perm){}
publicvoid checkPermission(Permission perm, Object context){}
}
Client code works fine if it is a simple application. The only difference to me was VM arguments and I added "codebase" and "policy" arguments but no change at all. (actually, rcp client already has stub file)
Is there any specific configuration I need to adjust to make it work?
Any help would be appreciated.
Thx
[2246 byte] By [
thexeromea] at [2007-11-26 17:45:09]

# 2
well, i have already read almost any stuff in your forum but it didnt help. clearly, I am doing something wrong here :)
VM args for Server:
-Djava.security.policy=${workspace_loc:/RMIServer/policy.all}
-Djava.rmi.server.codebase=file:${workspace_loc:/RMIServer/bin}
VM args for Client:
-Djava.rmi.server.codebase=file:${workspace_loc:/rcpclient}
-Djava.security.policy=${workspace_loc:/rcpclient/policy.all}
At first, client has no args and adding them did no difference.
It has the stub and custom securitymanager files under default package.
I googled for "registry lookup hangs". It says there is a bug using JPP. But I have no idea it is even related to this issue here.
# 4
okay, it wasnt hanged, it throws an exception.my bad..
java.lang.ClassCastException: HelloImpl_Stub
So, I remove the stub file from Client and change codebase arg to
-Djava.rmi.server.codebase=file:${workspace_loc:/RMIServer/bin}
didnt work..
Both classes are generated by same SDK (1.5). Client and server are running on same machine (local)
someone claimns to have a solution in your forum here:
http://www.genady.net/forum/viewtopic.php?t=205
and another one here:
http://forum.java.sun.com/thread.jspa?forumID=58&threadID=721143
here is the new code:
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
System.setSecurityManager(new MySecurityManager());
Registry registry = LocateRegistry.getRegistry("localhost", 1099);
Hello obj = (Hello) registry.lookup("HelloServer");
String message = obj.sayHello();
System.out.println(message);
Thread.currentThread().setContextClassLoader(oldLoader);
Still I get the same exception.
# 6
It always baffles me when people have this problem.
A remote object is an implementation of a remote interface, and it is transformed by RMI into a remote stub which implements the same remote interface.
So how can a different interface, i.e. the same interface in a different package, be the remote interface implemented by the remote object?
And where does it say you you can move/copy an interface from one package to another and retain binary compatibility?
ejpa at 2007-7-9 0:13:19 >
