RMI - downloading class definition?
Hello!
I am writing a little RMI application, where the server has access to a
database (sort of persistence layer), and the client sends search terms
to it over RMI.
The server loads the answer from the database into a JavaBean object
that is downloaded over the network so that the client can extract the
results from it. The javabean implements an interface with all the
exposed methods (get and set).
My question: Can RMI download the class definition from the server at
run-time, or do I need to have the class definition available at the
client as a .class file.
When I try to compile and run the client without having the bean class
definition (i.e. only using the methods in the interface it implements)
I get a security error message. This made me think that the client tries
to download the class definition, but fails due to security constraints.
I have tried to use a security policy file that grants the code base
where the server classes are located all permissions,
In the Main method of server I put:
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
and at the command line
java -Djava.security.policy=policyfile MyRMIServer
policyfile:
grant codeBase "file:/home/michaelp/rmiDB/" {
permission java.security.AllPermission;
};
but to no avail.The server wont even start... I get a security exception.
Greatful to any pointers:
Michael