2002 JI Open Discussion Posted August 17, 2006 Share Posted August 17, 2006 By: Thomas Richter - hornet_f4c Exceptions when using PDF OStream 2003-03-10 12:45 Hi there ... it's me again :-) My Server application directly streams the pdf reports to the client by using the follwing code: JasperRunManager.runReportToPdfStream(in,aResponse.getOutputStream();,params,aDataSource); The report works fine, still the method above frequently throws the follwing exception. Odd is that the report appears in the browser just as it should be.... Any ideas ? 2003-03-10 21:01:16,000 ERROR [HttpProcessor[8080][8]]: top_logic.pos.util.JasperReportsUtil - generatePdf(): An error occured while generating the pdf report - unable to run report java.net.SocketException: Connection aborted by peer: socket write error at java.net.SocketOutputStream.socketWrite(Native Method) at java.net.SocketOutputStream.write(SocketOutputStream.java:83) at org.apache.catalina.connector.ResponseBase.flushBuffer(ResponseBase.java:674) at org.apache.catalina.connector.HttpResponseBase.flushBuffer(HttpResponseBase.java:764) at org.apache.catalina.connector.ResponseBase.write(ResponseBase.java:647) at org.apache.catalina.connector.ResponseBase.write(ResponseBase.java:652) at org.apache.catalina.connector.ResponseStream.write(ResponseStream.java:312) at org.apache.catalina.connector.http.HttpResponseStream.write(HttpResponseStream.java:182) at dori.jasper.engine.JasperPrintManager.printReportToPdfStream(JasperPrintManager.java:174) at dori.jasper.engine.JasperRunManager.runReportToPdfStream(JasperRunManager.java:265) at com.top_logic.pos.util.JasperReportsUtil.generateJasperPdfToOutputStream(JasperReportsUtil.java:114) at com.top_logic.pos.util.JasperReportsUtil.generateJasperPdfToResponse(JasperReportsUtil.java:177) at com.top_logic.knowledge.gui.pos.view.report.workpackages.ReportWorkpackageBean.generatePdf(ReportWorkpackageBean.java:228) at java.lang.reflect.Method.invoke(Native Method) at com.top_logic.knowledge.gui.pos.base.BaseBean.dispatch(BaseBean.java:185) at com.top_logic.knowledge.gui.pos.POSContext.dispatch(POSContext.java:146) at com.top_logic.knowledge.gui.pos.POSControlServlet.doPost(POSControlServlet.java:77) at com.top_logic.knowledge.gui.pos.POSControlServlet.doGet(POSControlServlet.java:59) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at com.top_logic.util.TopLogicServlet.service(TopLogicServlet.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at com.top_logic.util.catalina.jar.FilteredValve.invoke(FilteredValve.java:100) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125) at java.lang.Thread.run(Thread.java:484) NESTED BY : dori.jasper.engine.JRException: Error writing to OutputStream : workpackages at dori.jasper.engine.JasperPrintManager.printReportToPdfStream(JasperPrintManager.java:178) at dori.jasper.engine.JasperRunManager.runReportToPdfStream(JasperRunManager.java:265) at com.top_logic.pos.util.JasperReportsUtil.generateJasperPdfToOutputStream(JasperReportsUtil.java:114) at com.top_logic.pos.util.JasperReportsUtil.generateJasperPdfToResponse(JasperReportsUtil.java:177) at com.top_logic.knowledge.gui.pos.view.report.workpackages.ReportWorkpackageBean.generatePdf(ReportWorkpackageBean.java:228) at java.lang.reflect.Method.invoke(Native Method) at com.top_logic.knowledge.gui.pos.base.BaseBean.dispatch(BaseBean.java:185) at com.top_logic.knowledge.gui.pos.POSContext.dispatch(POSContext.java:146) at com.top_logic.knowledge.gui.pos.POSControlServlet.doPost(POSControlServlet.java:77) at com.top_logic.knowledge.gui.pos.POSControlServlet.doGet(POSControlServlet.java:59) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at com.top_logic.util.TopLogicServlet.service(TopLogicServlet.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at com.top_logic.util.catalina.jar.FilteredValve.invoke(FilteredValve.java:100) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125) at java.lang.Thread.run(Thread.java:484) 2003-03-10 21:01:16,020 ERROR [HttpProcessor[8080][8]]: view.report.workpackages.ReportWorkpackageBean - ReportStructureElement::generatePdf(): unable to generate report. See previous logsfor details By: Thomas Richter - hornet_f4c As a sidenote... 2003-03-10 12:47 Each request from the client causes two threads to enter my method... strange. This is with Tomcat 4.04. Seems one thread does well (hence the expected outpur) and the other fucks up - hence the exception. But I am just giessing here.... By: Teodor Danciu - teodord RE: As a sidenote... 2003-03-11 00:37 Hi, I saw this behavior, but it seemed to me only Internet Explorer made two simultanious requests like you mentioned. Teodor By: nathan pitts - nathan1218 RE: As a sidenote... 2003-03-13 15:30 FYI: Windows2000: IE6, Netscape 4.7 exhibit the described behavior. Mozilla 1.3 does NOT do this... MacOSX (10.2.4): IE5.2, Mozilla 1.3b do NOT do this..... --Nathan By: Thomas Richter - hornet_f4c RE: Exceptions when using PDF OStream 2003-03-12 08:47 Hi Teo ! I managed to track this down and I can tell you, this is really weird. At first I may note that I have several other methods which also do binary streaming into the response (e.g. images) and with none of them did I ever see this two request phenomen. It is only when the request gets dispatched to a method which uses the JasperRunManager... then ALWAYS, two requests arrive from the client.... No, I am not drunk - And yes, I know this sounds strange. Finally I grabbed the method which does the jasper report. I removed the line "JasperRunManager.runReportToPdfStream(in,out,params,aDataSource);" and instead wrote some senseless stuff using out.print(). Guess what ?? After making this change, it worked !!!! Only one single request arrives my servlet and the browser shows excactly the string I wrote using out.print(); ... After simply reversing this change, the problem with the two requests occured again. Reproducable. Happens each and every time. I guess it is the follwowing: The first request is executed by the browser.... the pdf stream is read and as such the browser recognizes that it should launch the acrobat reader to display that document. But then it doesn't provide a cached document to the acrobat reader, but probably just the url. So the Acrobat reader sends a second request, finally downloading and displaying the document. Other than that it would have to be something inside the JasperRunManager which causes the effect. Because when streaming text or binary images the problem does not occur. It's only when delivering a pdf Stream.... which I currently do only using JasperReports. I guess the problem is on client side.... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now