• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Issue with sending xml jaxb object to servlet body

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been working on this simple call to a servlet that reads the xml passed to it but keep getting a 500 error. Could anyone point me in the right direction?

Here is the client code:



I cannot figure out what is wrong... Going crazy. I am simply creating a jaxb object and marshalling it to the servlet output stream.

Here is the servlet code:



Thanks for the help...

jaydev
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there nothing in the server logs, like a stack trace?
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A HTTP 500 error means that there is a serious and unhandled problem in the server side code.

In case of a Java webapplication, this generally means that there's an exception been thrown. If you don't see it (fully) in the error page itself (read the response), you normally can find the complete exception details and the trace back in the appserver's logs. This information should be enough to solve the problem yourself.
 
Julien Raynal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. I finally found some hint on Tomcat that indicates a "Premature enf of file" SAXParseException, which allowed me to figure out that when the servlet reads:



No data is being read, which means that for some reason, the jaxb object that is supposed to be written to the ouput stream on the client is not written. I am not sure why. Any suggestions would be great. I deugged the jaxb object and I know that it is not null and has data. Am I not writing correctly on the client?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to flush and close the outputstream. It's apparently buffered.
If that doesn't help, try invoking URLConnection#getInputStream().
reply
    Bookmark Topic Watch Topic
  • New Topic