This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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 .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Serializable Problem
 
Similar Threads
How to create unique Client ID
Locking/Unlocking, -- Am I Done Or I Don't Understand Requirements?
Lock Manager implementation
Final review - PLEASE READ
ConnectionFactoryImpl contains instance of Data or RemoteDataObject?