This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serializable Problem

 
Alex Qiu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DBConnectionRemote should extend UnicastRemoteObject in order to not to be Serialized and stay in the server
 
Alex Qiu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all , I got it .
Extends the UnicastRemoteObject to tell it stay in server , that is all .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic