• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Serializable Problem

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all , I got it .
Extends the UnicastRemoteObject to tell it stay in server , that is all .
 
Hey cool! They got a blimp! But I have a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic