• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI Exception! Please give me a hand!

 
allen gu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
allen gu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic