Issue with sending xml jaxb object to servlet body
Julien Raynal
Greenhorn
Joined: Apr 06, 2009
Posts: 2
posted
0
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.
Is there nothing in the server logs, like a stack trace?
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
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.
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
Joined: Oct 08, 2006
Posts: 2458
posted
0
You need to flush and close the outputstream. It's apparently buffered.
If that doesn't help, try invoking URLConnection#getInputStream().