Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RMI tutorial example - how to run from 2 machines?

7 views
Skip to first unread message

R@nsh!

unread,
Apr 22, 2003, 8:05:36 PM4/22/03
to
Hi.
Please see http://java.sun.com/docs/books/tutorial/rmi/running.html.
Running this example on one machine with the path's to simulate each user
works OK.
Now, if I try to put the server (ann, in this example) on one machine and
the client (jones) on another, when I start the client I get the following
trace.
what am I missing?
TIA,
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)
Caused by: java.lang.ClassNotFoundException: engine.ComputeEngine_Stub
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:427)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:159)
at
java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:631)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:257)
at
sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:200)
at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1513)
at
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
... 3 more


Gerbrand van Dieijen

unread,
Apr 23, 2003, 8:52:24 AM4/23/03
to
On Wed, 23 Apr 2003 02:05:36 +0200, R@nsh! wrote:
>Hi.
>Please see http://java.sun.com/docs/books/tutorial/rmi/running.html.
>Running this example on one machine with the path's to simulate each user
>works OK.
>Now, if I try to put the server (ann, in this example) on one machine and
>the client (jones) on another, when I start the client I get the following
>trace.
>what am I missing?

I got a headache of that sample too..

You have to set a policy file and put it in your homedirectory, it
is described on several tutorials.
It's pretty sick that that is needed, but user-friendly-ness (while still
being secure) is for some companies or organisations hard to grasp.

--
Gerbrand van Dieijen

WWW: http://twisted.warande.net
ICQ: 19345450

Sudsy

unread,
Apr 23, 2003, 11:19:35 AM4/23/03
to
"R@nsh!" <ran@~Qfish.com> wrote in message news:<3ea5...@news.012.net.il>...

> Hi.
> Please see http://java.sun.com/docs/books/tutorial/rmi/running.html.
> Running this example on one machine with the path's to simulate each user
> works OK.
> Now, if I try to put the server (ann, in this example) on one machine and
> the client (jones) on another, when I start the client I get the following
> trace.
> what am I missing?
> TIA,
> 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

Your client doesn't have access to the stub classes and so the
object being received can't be unmarshalled and instantiated.
Go back to the tutorial and find out what jars are needed on
the client side. You'll then either have to add them to your
CLASSPATH or add them to the $JAVA_HOME/jre/lib/ext directory.

Brian

unread,
Apr 28, 2003, 5:41:07 PM4/28/03
to
I was trying to get this tutorial to work on my Win2000 machine off of
localhost. I kept getting the ClassNotFoundException reported in this
original post when I tried to run the ComputeEngine. The last thing I
remember doing before it began working was running the rmiregistry in
the directory of my project:

C:\MyProjects\RMIDemo > start rmiregistry

I already had a batch file, and also the java.policy file:

I created a batch file with this:

set CLASSPATH=C:\MyProjects\RMIDemo
java -Djava.rmi.server.codebase=file:C:\MyProjects\RMIDemo
-Djava.rmi.server.hostname=localhost
-Djava.security.policy=java.policy engine.ComputeEngine

Now the damn thing works and I don't know what I did to get it working
except read this post.

I've gone from not being able to get it working, to not being able to
stop it from working. :-/ Maybe the classpath, though I didn't
change it...Mmm.

Brian

unread,
Apr 29, 2003, 11:50:54 PM4/29/03
to
bitbu...@hotmail.com (Sudsy) wrote in message
R@nsh,

You must have your ComputeEngine_* files at the location specified by
the
Djava.rmi.server.codebase

In my case, I was able to specify an http address to get the files,
such as
-Djava.rmi.server.codebase=http://.../classes/ (include trailing
slash!)


Without seeing the exact java command you're running, I can only guess
at the problem. But what's suppose to happen is that when you run
your client, the RMI system is suppose to send the ComputeEngine_*
files to your client from the location specified by the above
"codebase" location.

You shouldn't need to access these stub files from the classpath. The
whole point of the demo is that RMI will transfer the defintions
across the network to your client. All you need on the client side is
access to the compute.jar file and the client .class files. All the
server and stubs are elsewhere.

R@nsh!

unread,
Apr 30, 2003, 3:21:30 AM4/30/03
to
TnX, I will make another try later.
"Brian" <luc...@mediaone.net> wrote in message
news:961d6f35.03042...@posting.google.com...
0 new messages