aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI Exception! Please give me a hand!" Watch "RMI Exception! Please give me a hand!" New topic
Author

RMI Exception! Please give me a hand!

allen gu
Greenhorn

Joined: Jan 13, 2003
Posts: 6
Hi!
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;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection con=null;
String url="jdbc dbc:JICQ";
con=DriverManager.getConnection(url,"","");
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);
rs1.last();
int count=rs1.getRow();
if(count==0){
System.out.println("Null!");
}
else{
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);
if(!rs2.next()){
System.out.println("Some Exceptions!");
}
else{
String nick=rs2.getString("Nickname");
Person p=new Person(No,nick);
customers.addElement(p);
}
if((i+1)==count) {
break;
}
rs1.next();

}
}
return customers;
}
Thanx!
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11481
    
  94

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
Greenhorn

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