程序纠错?
出错信息:
java.rmi.MarshalException: error marshalling return; nested exception is:
java.io.NotSerializableException: cardtype.Zycard_type
源码:
package cardtype;
import java.io.*;
public class Zycard_type implements java.io.Serializable {
private Integer card_type_id;
private String descrip;
public Zycard_type(Integer card_type_id,String descrip) {
this.card_type_id=card_type_id;
this.descrip=descrip;
}
public Integer getcard_type_id(){
return card_type_id;
}
public void setcard_type_id(Integer card_type_id){
this.card_type_id=card_type_id;
}
public String getdescrip(){
return descrip;
}
public void setcard_type_id(String descrip){
this.descrip=descrip;
}
}
问题点数:50、回复次数:2Top
1 楼secrets001(tommyrot)回复于 2002-10-23 12:00:09 得分 50
你的这个程序肯定没有问题,我试了,绝对Serializable,所以问题不是出在这,找找别的吧。Top
2 楼chime(chime)回复于 2002-10-23 12:28:49 得分 0
是不是下面程序有错?但编译通过。
session bean 定议的接口:
public Zycard_type getZycard_type(Integer card_type_id) throws Exception, RemoteException;
session bean调用实体bean中的方法:
public Zycard_type getZycard_type (Integer card_type_id) {
try{
Context ctx = new InitialContext();
Object obj = ctx.lookup("ZycardType");
ZycardTypeHome zycardTypeHome = (ZycardTypeHome)PortableRemoteObject.narrow(obj, ZycardTypeHome.class);
ZycardType zycardType=zycardTypeHome.findByPrimaryKey(card_type_id);
return new Zycard_type(zycardType.getCardTypeId(),zycardType.getDescrip());
}catch (Exception ex) {
throw new EJBException(ex);
}
}
客户端调用:
public static void main(String[] args) {
ZycardtypeinsertTestClient2 client = new ZycardtypeinsertTestClient2();
Zycardtypeinsert bean = client.create();
try {
String descrip=bean.getZycard_type(new Integer(12345678)).getdescrip();
System.out.println(descrip);
}catch(Exception e)
{e.printStackTrace();};
Top




