Http POST input is unparseable
clarkester Apr 30, 2008 12:22 PMHi,
I am trying to use Seam in a non-JSF Web Application with version 2.0.0.GA.
I have a servlet in the app which receives XML messages and processes them.
My components.xml has
<web:context-filter url-pattern="/m/*" />
and I can see the Seam components being instantiated and invoked OK.
However, I get the following message in my logs
2008-04-30 10:59:33,086 DEBUG http-127.0.0.1-8080-1 [AbstractMessagingServlet] Extracting XML Document from HTTP Servlet Request... 2008-04-30 10:59:33,101 ERROR http-127.0.0.1-8080-1 [LoggerStream] [Fatal Error] :-1:-1: Premature end of file. 2008-04-30 10:59:33,101 DEBUG http-127.0.0.1-8080-1 [AbstractMessagingServlet] SAXException (Premature end of file.). Will try to dump raw request data... 2008-04-30 10:59:33,101 DEBUG http-127.0.0.1-8080-1 [AbstractMessagingServlet] Content-type: application/x-www-form-urlencoded 2008-04-30 10:59:33,101 DEBUG http-127.0.0.1-8080-1 [AbstractMessagingServlet] Content-Length: 575 2008-04-30 10:59:33,101 DEBUG http-127.0.0.1-8080-1 [AbstractMessagingServlet] Error trying to dump raw request data (sorry) java.io.IOException: mark/reset not supported
when I try and take the HttpServletRequest.getInputStream() and parse the contents into an XML Document using the following code:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document xmlDocument = builder.parse(request.getInputStream()); if (LOG.isDebugEnabled()) { LOG.debug("Dumping extracted XML Document..."); LOG.debug(DomHelper.toString(xmlDocument)); } return xmlDocument;
However, when I remove the Seam Filter from the XML message servlet
<filter-mapping> <filter-name>Seam Filter</filter-name> <url-pattern>/dummy/*</url-pattern> </filter-mapping>
I can parse the message without any problems.
Have you any idea why the stream is getting munged?
Cheers
Jon