オブジェクトのデシリアライズ中に次の例外が発生します。
コンソールへの出力
sending request: GET_OBJS
java.io.EOFException
receiving response
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readUTF(Unknown Source)
at java.io.ObjectInputStream.readUTF(Unknown Source)
at java.io.ObjectStreamClass.readNonProxy(Unknown Source)
at java.io.ObjectInputStream.readClassDescriptor(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at thesis.bot.wab.applet.DApplet.extracted(DApplet.java:218)
ファイルを使用せずにオブジェクトをデシリアライズしようとしています。オブジェクトは DatagramSocket を使用して送信されます。
私が呼び出すJavaアプレットから:
sendPacket("GET_OBJS");
[...]
input=new ObjectInputStream(new ByteArrayInputStream(receivedPacket.getData()));
objs=extracted(input);
toWrite=Integer.toString(objs.size());
input.close();
sendPacket("PRINT_"+toWrite);
[...]
private LinkedList<Objects> extracted(ObjectInputStream obj)
throws IOException, ClassNotFoundException {
return (LinkedList<Objects>) obj.readObject();
}
private void sendPacket(String msg) throws IOException{
System.out.println("sending request: "+msg);
buf=msg.getBytes();
DatagramPacket tosend=new DatagramPacket(buf,buf.length,addr,9999);
socket.send(tosend);
}
反対側:
else if(req.compareTo("GET_OBJS")==0){
Environement env=(Environement) ctx.getService(ctx.getServiceReference(Environement.class.getName()));
ByteArrayOutputStream baos=new ByteArrayOutputStream();
ObjectOutputStream out=new ObjectOutputStream(baos);
out.writeObject(env.getObjects());
out.close();
buf=baos.toByteArray();
resp="buffer_ready";
}
ここで、env.getObjects() は "Objects の LinkedList を返し、Objects はシリアライズ可能なクラスです。
どうしたの?