jQuery in Action, 3rd edition
The moose likes Distributed Java and the fly likes RMI Exception! Please give me a hand! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI Exception! Please give me a hand!" Watch "RMI Exception! Please give me a hand!" New topic

RMI Exception! Please give me a hand!

allen gu

Joined: Jan 13, 2003
Posts: 6
When a client invoke loginIn() ,the client throw a remoteException.
java.rmi.UnmarshalException:error unmarshalling return;nested exception is:
java.io.WriteAbortedException:writing aborted;
java.io.NotSerialzableException erson
I defined a Person class.
the code of loginIn() in the Server:
public Vector loginIn(int qno) throws Exception {
String sql1,sql2;
Vector customers=new Vector();
sql1="select * from relation_table where Customer1="+qno;
Connection con=null;
String url="jdbc dbc:JICQ";
Statement s1=con.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
Statement s2=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs1=s1.executeQuery(sql1);
int count=rs1.getRow();
rs1.first() ;
for(int i=0;i<count;i++){
int No=rs1.getInt("Customer2");
sql2="select * from login_table where qno="+No;
ResultSet rs2=s2.executeQuery(sql2);
System.out.println("Some Exceptions!");
String nick=rs2.getString("Nickname");
Person p=new Person(No,nick);
if((i+1)==count) {

return customers;
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11776

Hi Allen,
I take it that your Person class is on the server.
If you want your Person class to download to the client machine and run there, then you would make it implement Serializable.
If you want your Person class to run on the server, you would make it extend UnicastRemoteObject.
If you do not specify where you want your code to run, then RMI will check if your class is Serializable and give you the exception you have already noticed if it is not.
I wrote some code that demonstrates both ways of using RMI. You can find it at the bottom of this thread (second last post).
There are some tutorials listed on Sun's RMI page http://java.sun.com/j2se/1.4.1/docs/guide/rmi/
You might also want to look at the JGuru RMI short course at http://developer.java.sun.com/developer/onlineTraining/rmi/RMI.html
Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
allen gu

Joined: Jan 13, 2003
Posts: 6
I agree. Here's the link: http://aspose.com/file-tools
subject: RMI Exception! Please give me a hand!
It's not a secret anymore!