[java] Help with RMI

Started by
8 comments, last by Foobar of Integers 17 years ago
So, I have a small RMI demo app which has a few classes, Server, Client and NetworkInterface (which is the interface that the Server publishes to the RMI registry) Server starts up, sets up RMI, just sits idly in a thread, which is exactly what I wanted. I run the Client, it's all fine, it has no problem connecting and executing the server's methods. Ok, so this brings me to my problem: In Server's implementation of NetworkInterface, (which takes a reference to it's parent Server object when you create it) the methods published to RMI call another method on the Server object, which just for test purposes increments an int inside the Server instance (private int _myData) Each time I run the Client, (without killing the server, mind you) I expect the _myData to increase by 1. However, each time, it just gets reset to the initial value. So the problem I'm having is, how can I make the RMI methods actually change some internal server variables?
"ok, pac man is an old gameand, there are faces which is eatin up shits" - da madface
Advertisement
I'll be able yo help you if you can paste all of your code.

Cheers
It's a bit clunky to open up 5 rafb/paste windows, so here, I uploaded all the .java files:

http://www.acsu.buffalo.edu/~dhf2/rmidemo/

Client and Server are obvious (they both have main methods, when I run this I open up three consoles, one I do rmiregistry 1119, the other one I start server and then in the third I start client.

And NetworkImplementation is just the server's implementation of NetworkInterface.

"ok, pac man is an old gameand, there are faces which is eatin up shits" - da madface
Taking a look now.
Ok so i can't even get this running, i get:

C:\Users\Dave\Desktop\rmidemo>java Server
Exception: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: NetworkImplementation
RMI initialized.
Server thread started.

I assume you don't get that exception?
It's a problem with the classpath, I think. Don't run it from the directory with the .class files, go up a directory and do java rmidemo/Server

Don't forget to run "rmiregistry 1119" in another console before you start the server
"ok, pac man is an old gameand, there are faces which is eatin up shits" - da madface
I have tried all of that. I have removed the package declaration from each file to make it a bit easier.
Please, use the "source" tag and post your code, that way we all will be able to help you :D

[ source lang="java" ]
[ /source ]
a.k.a javabeats at yahoo.ca
I don't see what could be going wrong for you, but I exported the Eclipse project as a jar here and put it in the same directory as those .java files.

Also, I don't want to just post the code here, it's too long.
"ok, pac man is an old gameand, there are faces which is eatin up shits" - da madface
I found a tutorial on the net that might answer my question, so I'm gonna play with that for the night.
"ok, pac man is an old gameand, there are faces which is eatin up shits" - da madface

This topic is closed to new replies.

Advertisement