• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

dynamic code downloading problem with RMI

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My directory structure:
server:
C:\rmisample\server\
..\public\classes\engine\ComputeEngine_Stub.class
..\ComputeEngine_Skel.class
..\src\compute.jar
..\engine\ComputeEngine.class
client:
C:\rmisample\client\
..\public\classes\client\Pi.class
..\src\compute.jar
..\client\ComputePi.class
..\Pi.class
firstly, I start rmiregistry:
1) set classpath=
--I want to unset classpath, is right?
2) start rmiregistry
2. start server of engine.ComputeEngine int directory C:\rmisample\server\src>
java -classpath compute.jar;.
-Djava.rmi.server.codebase=file:/c:\rmisample\server\public\classes/
-Djava.rmi.server.hostname=localhost
-Djava.security.policy=java.policy
engine.ComputeEngine
3. run client program client.ComputePi in directory C:\rmisample\client\src>
java -classpath compute.jar;.
-Djava.rmi.server.codebase=file:/c:\rmisample\client\public\classes/
-Djava.security.policy=java.policy
client.ComputePi 10.194.72.80 20
it will work if they are run on the same PC.
but if I move the client part to the other one,
i cannot run the client and get the exception like this:
ComputePi exception: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: engine.ComputeEngine_Stub
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: engine.ComputeEngine_Stub
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:84)
at client.ComputePi.main(ComputePi.java:14)
if I copy the stub of server to the classpath of client,
it will work with two PCs.
this exception looks like from the setting of classpath of rmiregistry
but WHY? is it right i execute "set classpath=" to unset classpath?
(I'm using WindowsXP)
[ February 27, 2003: Message edited by: keisin syu ]
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To dynamically download the stubs, you need to have an HTTP server that is able to serve the subs upon request. That means that you must either write your own server or hope that the assessor has it running, in which case you still need to configure it. Both of these propositions are very risky. The consensus in this forum is that you don't need to implement dynamic code downloading. Simply package your stubs with the client, and you are done.
Eugene.
 
keisin syu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Eugene!
and I have another question about this topic, because the server need class Pi for ComputeEngine, and will upload Pi.class to the sever side.
is done by rmiregistry? why can it be done by the rmiregistry, but the stub is not?
 
keisin syu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm really doubting about the option of classpath now!
today I want to start sever engine.ComputeEngine, and got the exception saying that classloader cannot find the class of compute/Compute? how could it happen like this?
I'm using the same command as yesterday's, but it work smoothly yesterday!!
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


and I have another question about this topic, because the server need class Pi for ComputeEngine, and will upload Pi.class to the sever side.


Keisin,
This forum is to discuss the Java Developer Certification only, and your question would be better answered in the Sockets and Internet Protocols forum.
Eugene.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This problem cost me a lot of time too!

The basic Java tutorial on RMI does not make it clear that although RMI is capable of transporting an INSTANCE of a class via RMI, RMI does NOT transport a CLASS DEFINITION FILE.

This is much clearer in http://java.sun.com/j2se/1.3/docs/guide/rmi/codebase.html

RMI supplies a URL which specifies which protocol to use for the server and client codebase.
Option 1: file:/C:\mydisk\mycodebase\/
Option 2: http://MYWEBSERVER/rmiCodebase/
Option 3: ftp://MYFTPSERVER

Note that the protocol in option 1 (which you have been using) assumes that the server and client are co-resident.
Option 2 requires that you setup a webserver on BOTH client and server.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please keep to the topic of this forum SCJD. Dynamic code downloading in RMI is not currently allowed in an SCJD assignment solution.

Closing this topic and moving to our Distributed Java forum.
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic