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

NotSerializableException in RMI

1 view
Skip to first unread message

Class Account

unread,
Nov 1, 2000, 1:12:39 AM11/1/00
to
Hi, I am getting this error when I am doing RMI client-server stuff:

Exception in thread "main" java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.io.NotSerializableException: ClientIMImpl
java.io.NotSerializableException: ClientIMImpl
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java, Compiled Code)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java, Compiled Code)
at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java, Compiled Code)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java, Compiled Code)
at ServerAdminImpl_Stub.registerRemoteObjs(Unknown Source)
at simpleClient.main(simpleClient.java, Compiled Code)


Here's the interface and implementation of ClientIM:

import java.rmi.*;
import java.rmi.RemoteException;

/**
* ClientImManager provides an interface for peer-client to send instant message to this client
*/

public interface ClientIMIntf extends Remote {
public boolean instantMsg( String group, String senderID, String content ) throws RemoteException;
}

/*****************************************************************/

import java.rmi.*;
import java.io.*;

public class ClientIMImpl implements ClientIMIntf{

public ClientIMImpl() throws RemoteException{

}


public boolean instantMsg(String group, String senderID, String content ) throws RemoteException{
System.out.println(" client instantMsg ");
System.out.println("group: " + group);
System.out.println("senderID: " + senderID);
System.out.println("content: " + content);
return true;
}

}

Thank you for any help.


Kai

Kai Zhen Mai

unread,
Nov 1, 2000, 2:49:34 AM11/1/00
to
There's a remote server method called Register. Client A calls "Register"
to register its own ClientIM object to the server. Then when client B wants
to send instant message to client B for the first time, it askes the server
for the ClientIM object of A. WHen B gets the object, it just make the
remote method call to send the IM.
The problem is Javac keeps complaining that ClientIMImpl is not
serializable. I don't see anything that has not been serializable in
ClimentIMImpl.

Another question is when client calls register, is the reference or a copy
of THIS clientIM being sent? I guess it's the copy being sent.

Is there any better way to implement this client to client communication
model? any way to avoid going through the server? If I make the client as
a server as well, the client needs a hostname. That doesn't make sense cuz
most of online users' machine only have dynamics IP.

Thanks.
--

Kai
Please remove "~" from the email address when you reply by email
"Class Account" <cs16...@quasar.CS.Berkeley.EDU> wrote in message
news:8toc8n$8v4$1...@agate.berkeley.edu...

Gavin Spurling

unread,
Nov 1, 2000, 6:05:44 AM11/1/00
to
Surely you need to implement Serializable in either ClientIMImpl or
ClientIMIntf ? The java.rmi.Remote interface dosen't extend Serializable
already.

Ta.

Gavin.


"Class Account" <cs16...@quasar.CS.Berkeley.EDU> wrote in message
news:8toc8n$8v4$1...@agate.berkeley.edu...

0 new messages