'Stream closed' getting a XML from a Servlet

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

'Stream closed' getting a XML from a Servlet

aa aa-2
Hi:

I'm having problems modifying the bookcast sample in order to achieve that the XML was loaded from a Servlet. This is the code:




view:

            <xforms:submission id="sample-data-submission" serialize="false"
                       method="get" action="/AcceptData"
                       replace="instance" instance="books-instance"/>







Servlet /AcceptData:

           protected void doGet(HttpServletRequest request,
                                HttpServletResponse response)
                                throws ServletException, IOException {

                        try {
                                System.out.println(response);
                                String content = "<?xml version=\"1.0\" encoding=\"utf-8\"?><books>"+
                            "<book>"+
                        "<title>Don Quixote de la Mancha</title>"+
                        "<author>Miguel de Cervantes Saavedra</author>"+
                        "<language>es</language>"+
                        "<link>http://en.wikipedia.org/wiki/Don_Quixote</link>"+
                        "<rating>5</rating>"+
                        "<notes>Hola a todos.</notes>"+
                        "</book>" +
                        "</books>";
                                response.setContentType("application/xml");
                                response.getWriter().println(content.getBytes("UTF-8"));
                       
                        } catch (Exception e){
                                e.printStackTrace();
                        }
                }




The error I get is:
  java.io.IOException: Stream closed





And this is the stack in Eclipse:

Thread [http-8080-Processor24] (Suspended (exception IOException))
        BufferedInputStream.getBufIfOpen() line: not available
        BufferedInputStream.read() line: not available
        XMLEntityManager$RewindableInputStream.read() line: 2561
        XMLEntityManager.setupCurrentEntity(String, XMLInputSource, boolean, boolean) line: 969
        XMLVersionDetector.determineDocVersion(XMLInputSource) line: 184
        XIncludeParserConfiguration(XML11Configuration).parse(boolean) line: 792
        XIncludeParserConfiguration(XML11Configuration).parse(XMLInputSource) line: 758
        XercesSAXParser(XMLParser).parse(XMLInputSource) line: 148
        XercesSAXParser(AbstractSAXParser).parse(InputSource) line: 1178
        Sender.sendSAXSource(SAXSource, Receiver, int, int) line: 269
        Sender.send(Source, Receiver, boolean) line: 144
        IdentityTransformer.transform(Source, Result) line: 29
        TransformerWrapper.transform(Source, Result) line: 532
        TransformerUtils.readTinyTree(Source) line: 366
        TransformerUtils.readTinyTree(InputStream, String) line: 356
        XFormsModelSubmission.createErrorEvent(XFormsModelSubmission$ConnectionResult) line: 851
        XFormsModelSubmission.performDefaultAction(PipelineContext, XFormsEvent) line: 752
        XFormsContainingDocument.dispatchEvent(PipelineContext, XFormsEvent) line: 920
        XFormsSubmitControl.performDefaultAction(PipelineContext, XFormsEvent) line: 48
        XFormsContainingDocument.dispatchEvent(PipelineContext, XFormsEvent) line: 920
        XFormsContainingDocument.executeExternalEvent(PipelineContext, String, String, String, String, Element) line: 749
        XFormsServer.executeExternalEventPrepareIfNecessary(PipelineContext, XFormsContainingDocument, String, String, String, String, Element) line: 286
        XFormsServer.doIt(PipelineContext, ContentHandler) line: 241
        XFormsServer.access$000(XFormsServer, PipelineContext, ContentHandler) line: 46
        XFormsServer$1.readImpl(PipelineContext, ContentHandler) line: 75
        ProcessorImpl$6.read(PipelineContext, ContentHandler) line: 1012
        ProcessorImpl$ProcessorOutputImpl$ConcreteProcessorFilter$ForwarderProcessorOutput.read(PipelineContext, ContentHandler) line: 966
        ProcessorImpl.readInputAsSAX(PipelineContext, ProcessorInput, ContentHandler) line: 348
        MSVValidationProcessor.access$700(PipelineContext, ProcessorInput, ContentHandler) line: 44
        MSVValidationProcessor$5.readImpl(PipelineContext, ContentHandler) line: 219
        ProcessorImpl$6.read(PipelineContext, ContentHandler) line: 1012
        MSVValidationProcessor$5(ProcessorImpl$ProcessorOutputImpl).read(PipelineContext, ContentHandler) line: 1195
        ProcessorImpl$ProcessorOutputImpl$ConcreteProcessorFilter.read(PipelineContext, ContentHandler) line: 990
        XFormsServer$1(ProcessorImpl$ProcessorOutputImpl).read(PipelineContext, ContentHandler) line: 1195
        ProcessorImpl.readInputAsSAX(PipelineContext, ProcessorInput, ContentHandler) line: 348
        XMLSerializer.readInput(PipelineContext, ProcessorInput, HttpSerializerBase$Config, Writer) line: 58
        XMLSerializer(HttpTextSerializer).readInput(PipelineContext, ExternalContext$Response, ProcessorInput, Object, OutputStream) line: 54
        HttpSerializerBase$1.read(PipelineContext, ProcessorInput) line: 147
        XMLSerializer(ProcessorImpl).readCacheInputAsObject(PipelineContext, ProcessorInput, CacheableInputReader) line: 470
        XMLSerializer(HttpSerializerBase).start(PipelineContext) line: 138
        PipelineProcessor$11.run() line: 652
        PipelineProcessor(ProcessorImpl).executeChildren(PipelineContext, Runnable) line: 536
        PipelineProcessor.start(PipelineContext) line: 649
        ConcreteChooseProcessor.start(PipelineContext) line: 233
        PipelineProcessor$11.run() line: 652
        PipelineProcessor(ProcessorImpl).executeChildren(PipelineContext, Runnable) line: 536
        PipelineProcessor.start(PipelineContext) line: 649
        InitUtils.runProcessor(Processor, ExternalContext, PipelineContext, Logger) line: 88
        ProcessorService.service(boolean, ExternalContext, PipelineContext) line: 96
        OPSServletDelegate.service(HttpServletRequest, HttpServletResponse) line: 148
        OPSServletDelegate(HttpServlet).service(ServletRequest, ServletResponse) line: 803
        OPSServlet.service(HttpServletRequest, HttpServletResponse) line: 75
        OPSServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 803
        ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 269
        ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 188
        StandardWrapperValve.invoke(Request, Response) line: 210
        StandardContextValve.invoke(Request, Response) line: 174
        StandardHostValve.invoke(Request, Response) line: 127
        ErrorReportValve.invoke(Request, Response) line: 117
        StandardEngineValve.invoke(Request, Response) line: 108
        CoyoteAdapter.service(Request, Response) line: 151
        Http11Processor.process(InputStream, OutputStream) line: 870
        Http11Protocol$JmxHttp11ConnectionHandler(Http11BaseProtocol$Http11ConnectionHandler).processConnection(TcpConnection, Object[]) line: 665
        PoolTcpEndpoint.processSocket(Socket, TcpConnection, Object[]) line: 528
        LeaderFollowerWorkerThread.runIt(Object[]) line: 81
        ThreadPool$ControlRunnable.run() line: 685
        ThreadWithAttributes(Thread).run() line: not available

Any idea? Thanks a lot, it's very important for me to solve this issue.



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: 'Stream closed' getting a XML from a Servlet

Erik Bruchez
Administrator
First thing first: is your code in doGet() called? I.e. do you see the
result of the System.out.println()?

You can also try to enable XForms logging in RESOURCES/config/log4j.xml.
See:

http://www.orbeon.com/ops/doc/reference-xforms-2#xforms-logging

Then look at the logs to see where the submission fails.

-Erik

[hidden email] wrote:

> Hi:
>
> I'm having problems modifying the bookcast sample in order to achieve that the XML was loaded from a Servlet. This is the code:
>
>
>
>
> view:
>
>             <xforms:submission id="sample-data-submission" serialize="false"
>                        method="get" action="/AcceptData"
>                        replace="instance" instance="books-instance"/>
>
>
>
>
>
>
>
> Servlet /AcceptData:
>
>   protected void doGet(HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException, IOException {
>
> try {
> System.out.println(response);
> String content = "<?xml version=\"1.0\" encoding=\"utf-8\"?><books>"+
>    "<book>"+
>        "<title>Don Quixote de la Mancha</title>"+
>        "<author>Miguel de Cervantes Saavedra</author>"+
>        "<language>es</language>"+
>        "<link>http://en.wikipedia.org/wiki/Don_Quixote</link>"+
>        "<rating>5</rating>"+
>        "<notes>Hola a todos.</notes>"+
>        "</book>" +
>        "</books>";
> response.setContentType("application/xml");
> response.getWriter().println(content.getBytes("UTF-8"));
>
> } catch (Exception e){
> e.printStackTrace();
> }
> }
>
>
>
>
> The error I get is:
>   java.io.IOException: Stream closed
>
>
>
>
>
> And this is the stack in Eclipse:
>
> Thread [http-8080-Processor24] (Suspended (exception IOException))
> BufferedInputStream.getBufIfOpen() line: not available
> BufferedInputStream.read() line: not available
> XMLEntityManager$RewindableInputStream.read() line: 2561
> XMLEntityManager.setupCurrentEntity(String, XMLInputSource, boolean, boolean) line: 969
> XMLVersionDetector.determineDocVersion(XMLInputSource) line: 184
> XIncludeParserConfiguration(XML11Configuration).parse(boolean) line: 792
> XIncludeParserConfiguration(XML11Configuration).parse(XMLInputSource) line: 758
> XercesSAXParser(XMLParser).parse(XMLInputSource) line: 148
> XercesSAXParser(AbstractSAXParser).parse(InputSource) line: 1178
> Sender.sendSAXSource(SAXSource, Receiver, int, int) line: 269
> Sender.send(Source, Receiver, boolean) line: 144
> IdentityTransformer.transform(Source, Result) line: 29
> TransformerWrapper.transform(Source, Result) line: 532
> TransformerUtils.readTinyTree(Source) line: 366
> TransformerUtils.readTinyTree(InputStream, String) line: 356
> XFormsModelSubmission.createErrorEvent(XFormsModelSubmission$ConnectionResult) line: 851
> XFormsModelSubmission.performDefaultAction(PipelineContext, XFormsEvent) line: 752
> XFormsContainingDocument.dispatchEvent(PipelineContext, XFormsEvent) line: 920
> XFormsSubmitControl.performDefaultAction(PipelineContext, XFormsEvent) line: 48
> XFormsContainingDocument.dispatchEvent(PipelineContext, XFormsEvent) line: 920
> XFormsContainingDocument.executeExternalEvent(PipelineContext, String, String, String, String, Element) line: 749
> XFormsServer.executeExternalEventPrepareIfNecessary(PipelineContext, XFormsContainingDocument, String, String, String, String, Element) line: 286
> XFormsServer.doIt(PipelineContext, ContentHandler) line: 241
> XFormsServer.access$000(XFormsServer, PipelineContext, ContentHandler) line: 46
> XFormsServer$1.readImpl(PipelineContext, ContentHandler) line: 75
> ProcessorImpl$6.read(PipelineContext, ContentHandler) line: 1012
> ProcessorImpl$ProcessorOutputImpl$ConcreteProcessorFilter$ForwarderProcessorOutput.read(PipelineContext, ContentHandler) line: 966
> ProcessorImpl.readInputAsSAX(PipelineContext, ProcessorInput, ContentHandler) line: 348
> MSVValidationProcessor.access$700(PipelineContext, ProcessorInput, ContentHandler) line: 44
> MSVValidationProcessor$5.readImpl(PipelineContext, ContentHandler) line: 219
> ProcessorImpl$6.read(PipelineContext, ContentHandler) line: 1012
> MSVValidationProcessor$5(ProcessorImpl$ProcessorOutputImpl).read(PipelineContext, ContentHandler) line: 1195
> ProcessorImpl$ProcessorOutputImpl$ConcreteProcessorFilter.read(PipelineContext, ContentHandler) line: 990
> XFormsServer$1(ProcessorImpl$ProcessorOutputImpl).read(PipelineContext, ContentHandler) line: 1195
> ProcessorImpl.readInputAsSAX(PipelineContext, ProcessorInput, ContentHandler) line: 348
> XMLSerializer.readInput(PipelineContext, ProcessorInput, HttpSerializerBase$Config, Writer) line: 58
> XMLSerializer(HttpTextSerializer).readInput(PipelineContext, ExternalContext$Response, ProcessorInput, Object, OutputStream) line: 54
> HttpSerializerBase$1.read(PipelineContext, ProcessorInput) line: 147
> XMLSerializer(ProcessorImpl).readCacheInputAsObject(PipelineContext, ProcessorInput, CacheableInputReader) line: 470
> XMLSerializer(HttpSerializerBase).start(PipelineContext) line: 138
> PipelineProcessor$11.run() line: 652
> PipelineProcessor(ProcessorImpl).executeChildren(PipelineContext, Runnable) line: 536
> PipelineProcessor.start(PipelineContext) line: 649
> ConcreteChooseProcessor.start(PipelineContext) line: 233
> PipelineProcessor$11.run() line: 652
> PipelineProcessor(ProcessorImpl).executeChildren(PipelineContext, Runnable) line: 536
> PipelineProcessor.start(PipelineContext) line: 649
> InitUtils.runProcessor(Processor, ExternalContext, PipelineContext, Logger) line: 88
> ProcessorService.service(boolean, ExternalContext, PipelineContext) line: 96
> OPSServletDelegate.service(HttpServletRequest, HttpServletResponse) line: 148
> OPSServletDelegate(HttpServlet).service(ServletRequest, ServletResponse) line: 803
> OPSServlet.service(HttpServletRequest, HttpServletResponse) line: 75
> OPSServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 803
> ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 269
> ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 188
> StandardWrapperValve.invoke(Request, Response) line: 210
> StandardContextValve.invoke(Request, Response) line: 174
> StandardHostValve.invoke(Request, Response) line: 127
> ErrorReportValve.invoke(Request, Response) line: 117
> StandardEngineValve.invoke(Request, Response) line: 108
> CoyoteAdapter.service(Request, Response) line: 151
> Http11Processor.process(InputStream, OutputStream) line: 870
> Http11Protocol$JmxHttp11ConnectionHandler(Http11BaseProtocol$Http11ConnectionHandler).processConnection(TcpConnection, Object[]) line: 665
> PoolTcpEndpoint.processSocket(Socket, TcpConnection, Object[]) line: 528
> LeaderFollowerWorkerThread.runIt(Object[]) line: 81
> ThreadPool$ControlRunnable.run() line: 685
> ThreadWithAttributes(Thread).run() line: not available
>
> Any idea? Thanks a lot, it's very important for me to solve this issue.
>
>

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws