Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » java.lang.IllegalStateException: getOutputStream() has already been called for this response(java.lang.IllegalStateException: getOutputStream() has already been called for this response)
java.lang.IllegalStateException: getOutputStream() has already been called for this response [message #766845] Fri, 16 December 2011 09:32 Go to next message
Rohit  is currently offline Rohit
Messages: 1
Registered: December 2011
Junior Member
Hi,
I am using Birt in struts application with tiles.
When I tried execute code, i got following exception.

java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:611)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:173)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:889)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
at org.apache.jsp.WEB_002dINF.jsp.baseLayout_jsp._jspx_meth_tiles_005finsert_005f0(baseLayout_jsp.java:147)
at org.apache.jsp.WEB_002dINF.jsp.baseLayout_jsp._jspService(baseLayout_jsp.java:88)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1083)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:295)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:271)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:332)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)




It works fine in Web application using Servlets only.
But when i execute it through struts application.
It gives above exception.

Here is code where for action method


public ActionForward generateResignReport(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
LOGGER.info("Generate Resignation reprot");
ReportForm reportForm = (ReportForm) form;
EXCELRenderOption excelOptions = null;
PDFRenderOption pdfOptions = null;
String reportFile = "resignationReports.rptdesign";
ReportGenerator generator = new ReportGenerator();
IRunAndRenderTask task;
try {
if ((reportForm.getReportType()).equalsIgnoreCase("excel")) {
// Create task for rendering the reports
task = generator.createTask(request, reportFile);
// task.setParameterValue("RP_VERSIONNING", 0);
excelOptions = generator.generateExcelReport();
// response.resetBuffer();
response.setContentType("application/xls");
response.setHeader("Content-Disposition", "attachment; filename=\"ResignationListReport.xls\"");
excelOptions.setOutputStream(response.getOutputStream());
task.setRenderOption(excelOptions);
}
else {
// Create task for rendering the reports
task = generator.createTask(request, reportFile);
// task.setParameterValue("RP_VERSIONNING", 0);
pdfOptions = generator.generatePdfReport();
// response.resetBuffer();
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=\"ResignationListReport.pdf\"");
pdfOptions.setOutputStream(response.getOutputStream());
task.setRenderOption(pdfOptions);
}
// run report
task.run();
task.close();
}
catch (EngineException e) {
LOGGER.info("EngineException :" + e.getMessage());
}
catch (IOException e) {
LOGGER.info("IOException :" + e.getMessage());
}
catch (IllegalStateException e) {
LOGGER.info("IllegalStateException :" + e.getMessage());
}
return mapping.findForward("showReports");
}


Plz, If you have any suggestions for tackling this problem, let me know.
Thanks in advance.
Re: java.lang.IllegalStateException: getOutputStream() has already been called for this response [message #766921 is a reply to message #766845] Fri, 16 December 2011 11:49 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Take a look at this post, it is Struts 2 but it may be helpful.

http://birtworld.blogspot.com/2010/02/birt-and-struts-2.html

Specifically Struts 2 with the report engine.

Jason

On 12/16/2011 9:32 AM, Rohit wrote:
> Hi, I am using Birt in struts application with tiles.
> When I tried execute code, i got following exception.
>
> java.lang.IllegalStateException: getOutputStream() has already been
> called for this response
> at org.apache.catalina.connector.Response.getWriter(Response.java:611)
> at
> org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
>
> at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
> at
> org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
> at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:173)
> at
> org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:889)
>
> at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
> at
> org.apache.jsp.WEB_002dINF.jsp.baseLayout_jsp._jspx_meth_tiles_005finsert_005f0(baseLayout_jsp.java:147)
>
> at
> org.apache.jsp.WEB_002dINF.jsp.baseLayout_jsp._jspService(baseLayout_jsp.java:88)
>
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
>
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
> at
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
>
> at
> org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
>
> at
> org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
>
> at
> org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
>
> at
> org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1083)
>
> at
> org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:295)
>
> at
> org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:271)
>
> at
> org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:332)
>
> at
> org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
>
> at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
> at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
> at
> org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
>
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
>
> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
> at java.lang.Thread.run(Unknown Source)
>
>
>
> It works fine in Web application using Servlets only.
> But when i execute it through struts application.
> It gives above exception.
>
> Here is code where for action method
>
>
> public ActionForward generateResignReport(ActionMapping mapping,
> ActionForm form, HttpServletRequest request, HttpServletResponse response)
> {
> LOGGER.info("Generate Resignation reprot");
> ReportForm reportForm = (ReportForm) form;
> EXCELRenderOption excelOptions = null;
> PDFRenderOption pdfOptions = null;
> String reportFile = "resignationReports.rptdesign";
> ReportGenerator generator = new ReportGenerator();
> IRunAndRenderTask task;
> try {
> if ((reportForm.getReportType()).equalsIgnoreCase("excel")) {
> // Create task for rendering the reports
> task = generator.createTask(request, reportFile);
> // task.setParameterValue("RP_VERSIONNING", 0);
> excelOptions = generator.generateExcelReport();
> // response.resetBuffer();
> response.setContentType("application/xls");
> response.setHeader("Content-Disposition", "attachment;
> filename=\"ResignationListReport.xls\"");
> excelOptions.setOutputStream(response.getOutputStream());
> task.setRenderOption(excelOptions);
> }
> else {
> // Create task for rendering the reports
> task = generator.createTask(request, reportFile);
> // task.setParameterValue("RP_VERSIONNING", 0);
> pdfOptions = generator.generatePdfReport();
> // response.resetBuffer();
> response.setContentType("application/pdf");
> response.setHeader("Content-Disposition", "attachment;
> filename=\"ResignationListReport.pdf\"");
> pdfOptions.setOutputStream(response.getOutputStream());
> task.setRenderOption(pdfOptions);
> }
> // run report
> task.run();
> task.close();
> }
> catch (EngineException e) {
> LOGGER.info("EngineException :" + e.getMessage());
> }
> catch (IOException e) {
> LOGGER.info("IOException :" + e.getMessage());
> }
> catch (IllegalStateException e) {
> LOGGER.info("IllegalStateException :" + e.getMessage());
> }
> return mapping.findForward("showReports");
> }
>
> Plz, If you have any suggestions for tackling this problem, let me know.
> Thanks in advance.
Previous Topic:Programatically setting a value in crosstab cell
Next Topic:Dynamic BIRT help
Goto Forum:
  


Current Time: Tue Jul 22 21:49:36 EDT 2014

Powered by FUDForum. Page generated in 0.02751 seconds