aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Serializable Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Serializable Problem" Watch "Serializable Problem" New topic
Author

Serializable Problem

Alex Qiu
Greenhorn

Joined: Jul 19, 2002
Posts: 24
Hi all :
After reading a lot of the discussions here , I started my SCJD journey .
But now I encounter a problem .
I have a ConnectionFactory as the rmi server , which stores the LockManager and the Data class in the instance variable . It runs ok . But when trying the getConnection() method , it throws Exception , the getConnection() method is like this :
public void getConnection(){
DBConnection dbConn = new DBConnectionRemote(data ,lockManager);
}
And the constructor of DBConnectionRemote is :
public DBConnectionRemote(Data data ,LockManager lockManager) throws RemoteException {
dbLockManager = lockManager;
dbData = data ;
}
The Exception shows :
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: Writing aborted by exception; java.io.NotSerializableExceptio
n: suncertify.db.Data

After reading Mark Spritzler's article , I know that the data should not be Serliazable through server to client . But how to deal with it ? The DBConnectionRemote is already implements Remote . It should be identified as remote object ?
Any reply will be appreciated . Thank you in advance .


Nothing is impossible to a willing heart .<br />----------------------------------<br />SCJP SCJD
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Hi,
As per your exceptions. It seems that you had not used Serializable interface with the object that you want to transport. Make sure that the instance is tagged with Serializable interface.
Eduard Jodas
Ranch Hand

Joined: May 14, 2002
Posts: 80
DBConnectionRemote should extend UnicastRemoteObject in order to not to be Serialized and stay in the server
Alex Qiu
Greenhorn

Joined: Jul 19, 2002
Posts: 24
Thanks all , I got it .
Extends the UnicastRemoteObject to tell it stay in server , that is all .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Serializable Problem