wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Class directories for network mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Class directories for network mode" Watch "Class directories for network mode" New topic
Author

Class directories for network mode

Michael Tu
Greenhorn

Joined: Oct 14, 2002
Posts: 29
Hi, all,
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:
c:\...\suncertify\db
c:\...\suncertify\client
c:\...\suncertify\server

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.
Pete Lyons
Ranch Hand

Joined: Aug 18, 2002
Posts: 109
I was in the same situation. I would not worry about it. I ended up being able to remove my client classes from server.jar, but since My RMI classes belonged on the server side in terms of packaging, but were used by both sides, they needed to be in both jars.
jyothi sunke
Ranch Hand

Joined: Sep 11, 2002
Posts: 65
Hi Pete,
U mean that stub classes should present in both client and server jars. Is that right?? why do we need that?? we can set the rmi.server.codebase property on client side right!!! which will tell the client about server classes path.
Let me know if I am worng..
Thanks..


jyothi
Michael Tu
Greenhorn

Joined: Oct 14, 2002
Posts: 29
Thanks, jyothi. I think I must read sth about rmi.server.codebase
Michael
Michael Tu
Greenhorn

Joined: Oct 14, 2002
Posts: 29
Here is an excerpt from an article:
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?
Michael
Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194
Hi Michael,
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.


Mag
Michael Tu
Greenhorn

Joined: Oct 14, 2002
Posts: 29
Hi, Mag
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.
Michael
Richard Solomon
Greenhorn

Joined: Sep 12, 2002
Posts: 11
Hey Michael
What I did is, deployed the Remote interface and the stub along with the client.jar in the same packaging structure as required by the server.
There is no need to deploy the interface implementation and skels with the client.jar.
Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194
Hi Michael,
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.
ilwyvd illtvd
Greenhorn

Joined: Oct 20, 2002
Posts: 13
does this being permitted by Sun,Actually,in
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???
 
Consider Paul's rocket mass heater.
 
subject: Class directories for network mode
 
Similar Threads
Question on javadoc
The ultimate packaging question
"Overall Architecture"
problem executing executable jar file
UnmarshalException?? Please help