aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes reason for EOF exception? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "reason for EOF exception?" Watch "reason for EOF exception?" New topic
Author

reason for EOF exception?

Lukas Benberg
Ranch Hand

Joined: Jan 03, 2007
Posts: 45
hi all,
maybe someone can give me a hint where to start searching my problem?

i send a http post request to a remote server. that server then reads a url (a file) on my server and processes the text in it. as a result i get a response. here is my code:


the remote script obviously does read and processes my data, some output is generated. but it stops at some point and throws this exception:

java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2502)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1267)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
...

what could be the reason for this exception? the file on my server is intact. does the script on the remote server not work properly?

thanks for your help! l
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Can you perform the same operation with a browser?
Where is this ObjectInputStream? I would not expect HttpClient to use one. Are you using one in code you aren't showing us?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Dawei Li
Greenhorn

Joined: Jul 01, 2007
Posts: 22
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2502)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1267)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
hey 2502,1267,339 has relation with which line in your source?


<a href="http://www.java-forums.org" target="_blank" rel="nofollow">Java</a>
Lukas Benberg
Ranch Hand

Joined: Jan 03, 2007
Posts: 45
hi,
you are right, i use some more code and i guess that's where the problem is. i actually have two servlet classes: a "broker"-servlet who sends a http-message to a "communication"-servlet i mentioned above. the second one does the actual communication to the remote server. i think the communication between my own servlets fails. the exception refers to the broker-servlet.

broker-servlet:


communication-servlet:



obviously the ObjectInputStream in brokeRequest is the problem. do i have to create an ObjectOutputStream in doRemoteRequest? i would like to let the broker know if the request succeeded. how would i do this?

thanks! l
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

In order to use an ObjectInputStream to read an object, you must use an ObjectOutputStream to write an object (see here for a tutorial). What exactly does your URL reference?
Also, you say broker-servlet and communication-servlet are servlets, but they do not appear to implement the Servlet interface or its sub-interfaces. Do you understand how HTTP and Servlets work?
Lukas Benberg
Ranch Hand

Joined: Jan 03, 2007
Posts: 45
yes, the classes do extend HttpServlet, i only left out the irrelevant stuff. i think i understand what servlets do, though i am certainly not an expert. i'm not that familiar with http. thanks for the tutorial. i'll try to understand the ObjectOutputStreams. L
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reason for EOF exception?