Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

reason for EOF exception?

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Lukas Benberg
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic