Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Amine Amine
Download file problem
December 2, 2012 10:59 AM
Answer

Amine Amine

Rank: New Member

Posts: 21

Join Date: May 27, 2012

Recent Posts

Hello every body,
I use jasperreport for generating pdf and get this error when I want to download it

  1
  218:53:46,647 ERROR [ExceptionHandlerAjaxImpl:57]
  3java.lang.IllegalStateException
  4    at com.liferay.portal.servlet.filters.gzip.GZipResponse.getWriter(GZipResponse.java:122)
  5    at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:105)
  6    at com.liferay.portlet.MimeResponseImpl.getWriter(MimeResponseImpl.java:92)
  7    at com.liferay.faces.bridge.context.BridgeContextImpl.getResponseOutputWriter(BridgeContextImpl.java:1197)
  8    at com.liferay.faces.bridge.context.ExternalContextCompatImpl.getResponseOutputWriter(ExternalContextCompatImpl.java:664)
  9    at com.sun.faces.application.view.FaceletViewHandlingStrategy.createResponseWriter(FaceletViewHandlingStrategy.java:930)
 10    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:376)
 11    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
 12    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
 13    at com.liferay.faces.bridge.application.ViewHandlerCompatImpl.renderView(ViewHandlerCompatImpl.java:35)
 14    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
 15    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
 16    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 17    at com.liferay.faces.bridge.lifecycle.LifecycleWrapper.render(LifecycleWrapper.java:45)
 18    at com.liferay.faces.bridge.BridgePhaseResourceImpl.execute(BridgePhaseResourceImpl.java:103)
 19    at com.liferay.faces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:116)
 20    at javax.portlet.faces.GenericFacesPortlet.serveResource(GenericFacesPortlet.java:178)
 21    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:118)
 22    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:71)
 23    at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
 24    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 25    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 26    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 27    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
 28    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
 29    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 30    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 31    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
 32    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
 33    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
 34    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
 35    at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:531)
 36    at com.liferay.portlet.InvokerPortletImpl.invokeResource(InvokerPortletImpl.java:626)
 37    at com.liferay.portlet.InvokerPortletImpl.serveResource(InvokerPortletImpl.java:436)
 38    at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:1075)
 39    at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:719)
 40    at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:249)
 41    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
 42    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
 43    at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:176)
 44    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
 45    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
 46    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
 47    at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:560)
 48    at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:537)
 49    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 50    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 51    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 52    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
 53    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 54    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 55    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 56    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 57    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 58    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 59    at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:294)
 60    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
 61    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
 62    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
 63    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
 64    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 65    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 66    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
 67    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
 68    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
 69    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
 70    at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:138)
 71    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 72    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 73    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 74    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
 75    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 76    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 77    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 78    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 79    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 80    at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
 81    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
 82    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
 83    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
 84    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 85    at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:294)
 86    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
 87    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
 88    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
 89    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 90    at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:241)
 91    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
 92    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
 93    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
 94    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 95    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 96    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 97    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 98    at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:246)
 99    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
100    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
101    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
102    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
103    at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
104    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
105    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
106    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
107    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
108    at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:80)
109    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
110    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
111    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
112    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
113    at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:216)
114    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
115    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
116    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
117    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:187)
118    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
119    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
120    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
121    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
122    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
123    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)


Here is my function

 1
 2public void exportToPdf(ActionEvent event) {
 3        try {
 4            Connection connection = null;
 5            JasperPrint jasperPrint=null;
 6                        Driver driver = new com.mysql.jdbc.Driver();
 7                        DriverManager.registerDriver(driver);
 8                        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/liferay", "root", "root");
 9                        // - Chargement et compilation du rapport
10                        JasperDesign jasperDesign = JRXmlLoader.load("C:\\eclipse\\workspace\\ManageReport\\src\\main\\resources\\template\\OALIA_HelpDesk_Summary.jrxml");
11                        JasperReport jasperReport = JasperCompileManager
12                                .compileReport(jasperDesign);
13                        // - Paramètres à envoyer au rapport
14                        Map parameters = new HashMap();
15                        parameters.put("projectid",(float)10000);
16                        // - Execution du rapport
17                        jasperPrint = JasperFillManager.fillReport(
18                                jasperReport, parameters, connection);
19            PortletResponse portletResponse = (PortletResponse) FacesContext
20                    .getCurrentInstance().getExternalContext().getResponse();
21            HttpServletResponse httpservletresponse = com.liferay.portal.util.PortalUtil
22                    .getHttpServletResponse(portletResponse);
23            httpservletresponse.addHeader("Content-disposition",
24                    "attachment; filename=RapportSupport.pdf");
25            ServletOutputStream servletoutputstream = httpservletresponse
26                    .getOutputStream();
27            // - Création du rapport au format PDF
28            JasperExportManager.exportReportToPdfStream(jasperPrint,
29                    servletoutputstream);
30        } catch (Exception e) {
31            e.printStackTrace();
32        }
33    }


Please help me it's very important that i find a solution
Thank you
David H Nebinger
RE: Download file problem
December 2, 2012 6:32 PM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7078

Join Date: September 1, 2006

Recent Posts

You cannot do something like this...

You're trying to take over the whole output stream, but the portal has already started writing to it. You cannot return a pdf file in this way.
Amine Amine
RE: Download file problem
December 2, 2012 11:36 PM
Answer

Amine Amine

Rank: New Member

Posts: 21

Join Date: May 27, 2012

Recent Posts

Hello david,
Thank you for your response
How can i download liferay using jasper and jsf from portlet
Imran Khalil
RE: Download file problem
December 2, 2012 11:51 PM
Answer

Imran Khalil

Rank: Junior Member

Posts: 36

Join Date: October 21, 2012

Recent Posts

I am having same issue... Any help?
Neil Griffin
RE: Download file problem
December 6, 2012 2:37 PM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2105

Join Date: July 26, 2005

Recent Posts

I would recommend that you download the jsf2-export-pdf-portlet demo. It uses a custom JSF ResourceHandler invoked via Ajax (the portlet RESOURCE_PHASE) in order to download a PDF.