File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes RMI, dynamically load class into server, rmiregistry CLASSPATH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI, dynamically load class into server, rmiregistry CLASSPATH" Watch "RMI, dynamically load class into server, rmiregistry CLASSPATH" New topic
Author

RMI, dynamically load class into server, rmiregistry CLASSPATH

John Denton
Greenhorn

Joined: Mar 05, 2012
Posts: 1
Hello.

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.

Server:

compute/ComputeEngine.java:

Client:

client/ComputeLong:

client/LongTask.java

Shared:
shared/Compute.java:

shared/Task.java:


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):

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI, dynamically load class into server, rmiregistry CLASSPATH
 
Similar Threads
Classpath Issue
Eclipse wont run my RMI program?
HFJ - RMI issues.
cant run java file from command line but works with .sh file??
no security manager: RMI class loader disabled