Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Java RMI problem

Hi guys,

I am having a strange problem using Java RMI. I am building a chat program in Java 5 Tiger, using the RMI framework and Java seems to be caching one of my interface implementations, as when I change a line of code, it still seems to use a previous one.

An example is:

the first line of code i had, which i was using to test that the server side was sending RMI messages back to the client side, which worked and printed the message out as required.

public void recvBroadcast(String userName,String message) throws java.rmi.RemoteException{
System.out.println(userName + "says: " + message);
}

I then changed the code to below, but I still got the same message printed out to screen, rather than to the required textPane.

public void recvBroadcast(String userName,String message) throws java.rmi.RemoteException{
gui.txtPaneChat.setText(userName + "says: " + message);
}

I am thinking that perhaps i need to clear the java cache, or rmiregistry or something but I do not know how to do this.

Please help, this is very frustrating!

Cheers guys
[1166 byte] By [sportacus] at [2007-11-11 7:21:40]
# 1 Re: Java RMI problem
Did you try stopping and starting the RMI registry?
Or perhaps generate a new proxy / stub?
ractoc at 2007-11-11 22:38:34 >
# 2 Re: Java RMI problem
Yes, I have indeed tried to restart the rmiregistry.

I am affraid I do not know how to generate a new proxy / stub. Could you elaborate please?

Thank you
sportacus at 2007-11-11 22:39:34 >
# 3 Re: Java RMI problem
Well, to get the RMI to work in the first place, you have to do some things with your code and a external program, which generates 2 new class files, the proxy and the stub. (I'm not sure about the name of the program since I don't have my books here...)

It might be that you accidentally deleted you class file directory, which holds those files.
ractoc at 2007-11-11 22:40:37 >
# 4 Re: Java RMI problem
I do not that this is the problem because RMI is working because I am successfuly connecting to the server and it is indeed connecting and returning data to the client.

Unfortunately, the data is being sent to the command window rather that the gui, as though it is reading the System.out.println instead of the txtPane.setText() line of code.

I am utterly confused as the program continues to print out this line of code that does not exist!

Any more suggestions would be most welcome.

Thank you
sportacus at 2007-11-11 22:41:37 >
# 5 Re: Java RMI problem
Did you delete you class files before recompiling?
because I discovered that sometimes the compiler doesn't overwrite classfiles already there, even though they have changed.
ractoc at 2007-11-11 22:42:41 >