Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issue with sending xml jaxb object to servlet body

 
Julien Raynal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there nothing in the server logs, like a stack trace?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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().
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic