banq,你好!我做了自己的Chat,但除錯時發現sendrequest()出錯

gmslzm發表於2005-08-23
banq,你好!我做了自己的Chat,但除錯時發現sendrequest()出錯,錯誤如下:
05-8-23 10:35:57 [Debug:com.jdon.jserver.connector.SocketDataHandler:Error] sendRequest() error:java.lang.NullPointerException
05-8-23 10:35:57 [Debug:com.jdon.jserver.connector.udp.UDPClient:Error] run error:java.lang.Exception: java.lang.NullPointerException
是這樣的,我自己試著建立了一個物件:
public final class MsgObj {
public String phoneNo="";
public String msgInfo="";
public String msgType="";
public MsgObj() {
}
}
然後根據物件又建立了"被訪問者"如下:
public class MsgObjType implements Linkable {
private MsgObj content=null;
private int msgType;
private ByteBuffer byteBuffer=null;
public MsgObjType(int msgType) {
this.msgType=msgType;
}
public MsgObj getContent(){
return content;
}
public void setContent(MsgObj content){
this.content=content;
}
public void accpet(QueueWorker worker) throws Exception {
worker.run(msgType,this);
}

public OutputStream getOutputStream() {
OutputStream outputStream=null;
try {
outputStream = DataTypeHelper.writeObject(content);
}
catch (Exception ex) {
ex.printStackTrace();
}
return outputStream;
}

public void setInputStream(InputStream in) {
try {
this.content = (MsgObj)DataTypeHelper.getObject(in);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
在向伺服器端傳送時就發生了以上錯誤,難道MsgObj需要Serializable嗎?請指教,謝謝!

相關文章