Just one thing not clear: how to deploy class files for network mode?
In my development environment, I have three packages: suncertify.db, suncertify.client, suncertify.server in directories like:
In production, for example, two machines are avaliable for network mode: one used as server, one as workstation. To my thinking, I shall not:
(a) put any single file from suncertify.client in the server machine;
(b) put any classes from suncertify.server in client workstation.
For (a), no problem. However, if I practice (b), it won't work. This looks unacceptable to me. Since if you are only a remote user, why you bother to have server side files in your workstation?
I must have sth wrong here. Can anyone advise me? Thanks.
The basic concept is that the server stub class should not have to be both on the client and server. The trick is to get the server stub from the server to the client.
1. When the stub code is only on the server, the way to get it to the client is not through the rmi service, but through http. So, in order for dynamic stub loading to work, the rmi server must also be a web server.
2. The stub classes on the server must be placed where an http request can get to them. This can usually be the $HOME/public_html subdirectory (or any subdirectory therof). ($HOME means the user's home directory)
3. The server codebase must be set to the URL where the stubs where placed:
java -Djava.rmi.server.codebase=http://serverhost/~username/rmi/ ClientMain serverhost
where serverhost is the server hostname, username is the user's home directory name. In this example, the server stubs were placed in an rmi subdirectory of public_html.
The most importany point of all this is that the codebase should be set on the CLIENT java execution, not the server.
It says the URL for codebase must start with http:// and the server must be a web server! Apparently, this is not the case for our FBN server, neither from the assignment specs nor practical implementation.
Then, what should we do? Put all the server classes in the client machine? Is this all right?
having the stubs classes in the client's classpath is a matter of security.
Normally, RMI provides that the client downloads the stubs from the server. But the client must have the explicit permission to do so - since the remote machine is a "stranger".
However, the client does not need to download the stubs from the server, but may also load it its classpath. And in this case no security management is required.
Hope this helps.
Yes, it works if keep the _stub classes in the client side provide CLASSPATH is set correctly. The directories to put _stub classes follow the same rule of package directories. For example, I can put \suncertify\server\*_stub.class under whatever directory and set classpath to this directory.
However, what's the proper way to jar the three packages?
For example, if I jar the packages separately into client.jar, server.jar and db.jar. Again, in client side, I have to deploy all the three jar files. How can I deploy only those files for client to work (i.e. include the _stub.class only)?
Pls guide. thanks.
I had two packages, the server.jar, and the client.jar. The server.jar contained all server-side stuff, and the client.jar contained the client-side stuff. However, the client's manifest required the server.jar being in the same directory as the client.jar for running the client (that's how I solved the problem, and passed).
Hope this helps.
some situation you package the server side in servre.jar, client side in client.jar,you can
use java.rmi.server.code to get the stub,but it
type too many words,I believe use Class-Path server.jar in mainifest.mf may be a good way,but
I doubt is it being approved by Sun???