EOFException at ObjectInputStream

D

David Baer

I get the following EOFException at ObjectInputStream.readObject:

java.io.EOFException
at
java.io_ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2435)
at
java.io_ObjectInputStream.skipCustomData(ObjectInputStream.java:1798)
at
java.io_ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1519)
at
java.io_ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at
java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at
java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io_ObjectInputStream.readObject(ObjectInputStream.java:324)


Server Side Code parts:
public int readFromClient(){
Object obj = null;
try {
obj = fromClient.readObject();
(...)


public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException {
ObjectInputStream fromClient = null;
ObjectOutputStream toClient = null;
try {
toClient = new ObjectOutputStream(response.getOutputStream());
fromClient = new ObjectInputStream(request.getInputStream());
(...)


I'm happy to post more code if needed.

can anybody help me with this exception?

thanks!
dave
 
R

Ricardo

David said:
I get the following EOFException at ObjectInputStream.readObject:

java.io.EOFException
at
java.io_ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2435)
at
java.io_ObjectInputStream.skipCustomData(ObjectInputStream.java:1798)
at
java.io_ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1519)
at
java.io_ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at
java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at
java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io_ObjectInputStream.readObject(ObjectInputStream.java:324)


Server Side Code parts:
public int readFromClient(){
Object obj = null;
try {
obj = fromClient.readObject();
(...)


public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException {
ObjectInputStream fromClient = null;
ObjectOutputStream toClient = null;
try {
toClient = new ObjectOutputStream(response.getOutputStream());
fromClient = new ObjectInputStream(request.getInputStream());
(...)


I'm happy to post more code if needed.

can anybody help me with this exception?

thanks!
dave

Does your client flush?

( toServer.flush() )
 
D

David Baer

Ricardo said:
Does your client flush?

( toServer.flush() )

yes (i think so). this is my client code:

URL url = new URL(host);
httpCon = (HttpURLConnection) url.openConnection();
httpCon.setDoOutput(true);
httpCon.setDoInput(true);
//httpCon.setRequestProperty("Content-Type", "application/octet-stream");
toServer = new ObjectOutputStream(httpCon.getOutputStream());




InputStream in = null;
try {
in = httpCon.getInputStream();
}
catch (Exception e) {
e.printStackTrace();
}
fromServer = new ObjectInputStream(in);
toServer.writeObject(msg);
toServer.flush();

I think I had this same code before and it worked. I'm using tomcat on the
server-side.

thanks for hints
dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top