RMI, dynamically load class into server, rmiregistry CLASSPATH
posted 3 years ago
I've done some RMI examples before but I haven't tried dynamically loading code to server yet. So I looked up RMI tutorial and slightly modified the example. First I started rmiregistry in my home directory (eg. away from CLASSPATH of my two projects), then I created server & client projects. The reason for two projects is to not share CLASSPATH. Then I tried to execute server main() (compute/ComputeEngine.java) but RMI fails to get shared/Compute.java interface (exception & code below). I tried to start registry inside server main() (eg. createRegistry(int) instead of getRegistry(int)) or start rmiregistry program in directory with compiled server classes and server startup worked. However now client main() (client/ComputeLong.java) threw same exception. According to tutorial, rmiregistry shouldn't have access to any CLASSPATH. My goal is to execute class unknown to server (implementing common interface) in server. What am I doing wrong? Thank you.
For clarity I omitted policy related files (they work, I tried it with command line settings too). Task and Compute interfaces are copy-pasted between projects but they're same.
This exception is from server project, but it looks exactly same in client (rmi-test-client):