java.lang.IllegalStateException: Cannot obtain OutputStream because Writer is already in use

Icesoft | Lazarus__ | 5 years ago
  1. 0

    Problems trying to use show a pdf file create with jasper icefaces 1.8 liferay

    Icesoft | 5 years ago | Lazarus__
    java.lang.IllegalStateException: Cannot obtain OutputStream because Writer is already in use
  2. 0

    Simple JSF Ajax causes ViewExpiredException on Weblogic - Forums | Liferay

    liferay.com | 1 year ago
    java.lang.IllegalStateException: Cannot obtain OutputStream because Writer is already in use
  3. 0

    Exception in getting OutputStream from response object - Forums | Liferay

    liferay.com | 8 months ago
    java.lang.IllegalStateException: Cannot obtain Writer because OutputStream is already in use
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    where use in action response.getOutputStream() FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); PortletResponse portletResponse = (PortletResponse) externalContext.getResponse(); HttpServletResponse response = PortalUtil.getHttpServletResponse(portletResponse); //ReportConfigUtil.compileReport(context, getCompileDir(), raportFileName); File reportFile = new File(ReportConfigUtil.getJasperFilePath(externalContext, getCompileDir(), raportFileName + ".jasper")); JasperPrint jasperPrint = ReportConfigUtil.fillReport(reportFile, params, dataSource); FileBufferedOutputStream fbos = new FileBufferedOutputStream(); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, fbos); try { exporter.exportReport(); fbos.close(); if (fbos.size() > 0) { String filename = raportFileName + System.currentTimeMillis() + ".pdf"; response.reset(); response.setContentType("application/pdf"); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); response.setContentType("application/force-download"); response.setCharacterEncoding("UTF-8"); response.setContentLength(fbos.size()); ServletOutputStream ouputStream = response.getOutputStream(); try { fbos.writeData(ouputStream); fbos.dispose(); ouputStream.flush(); } finally { if (ouputStream != null) { try { ouputStream.close(); } catch (IOException ex) { } } } //response. } } finally { fbos.close(); fbos.dispose(); } response.flushBuffer(); response.setStatus(HttpServletResponse.SC_OK); facesContext.responseComplete(); The system generates an error: 7:01:45,756 ERROR [[Friendly URL Servlet - Public]] Servlet.service() for servlet Friendly URL Servlet - Public threw exception java.lang.IllegalStateException: Cannot obtain Writer because OutputStream is already in use at com.liferay.portal.kernel.servlet.StringServletResponse.getWriter(StringServletResponse.java:111) 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.PageContextImpl.release(PageContextImpl.java:180) at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:118) at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:77) at org.apache.jsp.html.common.themes.portal_jsp._jspService(portal_jsp.java:757) 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:369) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249) 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:638) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:543) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:480) at com.liferay.portal.struts.StrutsUtil.include(StrutsUtil.java:135) at com.liferay.portal.struts.PortalRequestProcessor.doInclude(PortalRequestProcessor.java:265) at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:237) at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:302) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241) at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:152) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

    Liferay Issues | 6 years ago | Waldemar Kłaczyński
    java.lang.IllegalStateException: Cannot obtain Writer because OutputStream is already in use
  6. 0

    Simple JSF Ajax causes ViewExpiredException on Weblogic - Forums | Liferay

    liferay.com | 12 months ago
    java.lang.IllegalStateException: Cannot obtain OutputStream because Writer is already in use

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Cannot obtain OutputStream because Writer is already in use

      at com.liferay.portal.kernel.servlet.StringServletResponse.getOutputStream()
    2. Liferay Portal Service
      StringServletResponse.getOutputStream
      1. com.liferay.portal.kernel.servlet.StringServletResponse.getOutputStream(StringServletResponse.java:62)
      1 frame
    3. picas
      JsfUtility.print
      1. picas.JsfUtility.print(JsfUtility.java:714)
      1 frame
    4. org.picas.managedbeans
      AnnunciAz.stampatmp
      1. org.picas.managedbeans.azienda.AnnunciAz.stampatmp(AnnunciAz.java:160)
      1 frame
    5. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    6. Pax Jsp
      MethodExpressionImpl.invoke
      1. org.apache.el.parser.AstValue.invoke(AstValue.java:170)
      2. org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      2 frames
    7. JSF
      ActionListenerImpl.processAction
      1. com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
      2. com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
      2 frames
    8. JavaEE 7
      UIViewRoot.processApplication
      1. javax.faces.component.UICommand.broadcast(UICommand.java:383)
      2. javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
      3. javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
      3 frames
    9. JSF
      LifecycleImpl.execute
      1. com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
      2. com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      3. com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      3 frames
    10. com.icesoft.faces
      MainServlet.service
      1. com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
      2. com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:132)
      3. com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:74)
      4. com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:31)
      5. com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
      6. com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
      7. com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
      8. com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
      9. com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:26)
      10. com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
      11. com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:131)
      11 frames