Hi All,
I have develop a SpringMVC-portlet and I am trying to generate three kind of report i.e. Web, PDF, Excel form. I am successful in generating Web Report but When I am trying to get PDF and Excel I am getting such exception: I am not understanding this ExceptionConvertor, If any hint is added here will be very wonderful for me.
Thank you
__________________________________________________________________________________________________
Caused by: ExceptionConverter: ClientAbortException: java.io.IOException
21:17:54,921 ERROR [http-apr-8080-exec-12][PortletServlet:115] javax.portlet.PortletException: Request processing failed
javax.portlet.PortletException: Request processing failed
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:545)
at org.springframework.web.portlet.FrameworkPortlet.serveResource(FrameworkPortlet.java:478)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:118)
........................... cont....................
Caused by: javax.servlet.ServletException: ExceptionConverter: ClientAbortException: java.io.IOException
at com.bfds.portal.complus.reports.controller.ComplusController.sendOutput(ComplusController.java:342)
at com.bfds.portal.complus.reports.controller.ComplusController.complusReport(ComplusController.java:269)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
Where ComplusController.java has this set of code: To generate report.
______________________________________________________________________________________
private void sendOutput(ResourceRequest resourceRequest, ResourceResponse resourceResponse,
ReportInfo rptInfo) throws ServletException, PortletException, IOException {
ReportWriter rw = new ReportWriter(resourceResponse.getPortletOutputStream());
String metric = resourceRequest.getParameter("metric");
String outputType = resourceRequest.getParameter("outputType");
try {
if (metric != null) {
rw.writeHtmlDetail(rptInfo, metric);
} else {
// Check and set output document type.
if (PDF.equals(outputType)) {
/* This updates the HTML header so it must be the first thing output. */
HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(resourceResponse);
ServletOutputStream out = httpResponse.getOutputStream();
httpResponse.setContentType(PDF_CONTENT_TYPE);
httpResponse.setHeader("Content-Disposition",
" inline; filename=\"" + FILENAME + ".pdf\"");
/*resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.setContentLength(baos.size());*/
// Format and output the report results ...
rw.writePdf(rptInfo);
return;
} else if (EXCEL.equals(outputType)) {
HSSFWorkbook wb = new HSSFWorkbook();
HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(resourceResponse);
ServletOutputStream out = httpResponse.getOutputStream();
/* This updates the HTML header so it must be the first thing output. */
resourceResponse.setContentType(EXCEL_CONTENT_TYPE);
((HttpServletResponse) resourceResponse).setHeader("Content-Disposition",
" inline; filename=\"" + FILENAME + ".xls\"");
/*resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
OutputStream out = resourceResponse.getPortletOutputStream();
wb.write(out);
out.flush();
out.close();*/
rw.writeExcel(rptInfo);
return;
} else {
// else HTML ...
// Format and output the report results ...
String str = rptInfo.toString();
rw.writeHtml(rptInfo);
}
}
} catch (Exception ex) {
throw new ServletException(ex);
}
}
Please sign in to flag this as inappropriate.