cancel
Showing results for 
Search instead for 
Did you mean: 

Stream closed [Error]

gonial
Champ in-the-making
Champ in-the-making
Buenos días de nuevo.

Mi aplicacion web sigue adelante y cuando tenia ya todo lo necesario con alfresco bien definido, a unos dias de presentar el producto me encuentro con este error "java.io.IOException: Stream closed"

En principio muestro una lista de resultados, los cuales unos tienen asociados documentos en alfresco y otros no, pues si despues de estar pulsando sobre los elementos que tienen asociado en alfresco algun documento, paso a pulsar sobre un elmento que no tiene documento asociado, me salta el siguiente error: 


jul 30, 2015 10:07:33 AM com.sun.faces.lifecycle.InvokeApplicationPhase execute
ADVERTENCIA: java.io.IOException: Stream closed
javax.faces.FacesException: java.io.IOException: Stream closed
   at org.primefaces.component.filedownload.FileDownloadActionListener.processAction(FileDownloadActionListener.java:90)
   at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
   at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:813)
   at javax.faces.component.UICommand.broadcast(UICommand.java:300)
   at javax.faces.component.UIData.broadcast(UIData.java:1108)
   at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
   at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
   at alfresco.modelbd.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:52)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
   at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Stream closed
   at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162)
   at java.io.BufferedInputStream.read(BufferedInputStream.java:325)
   at java.io.FilterInputStream.read(FilterInputStream.java:107)
   at org.primefaces.component.filedownload.FileDownloadActionListener.processAction(FileDownloadActionListener.java:81)
   … 33 more

jul 30, 2015 10:07:33 AM com.sun.faces.context.ExceptionHandlerImpl log
1100: JSF1073: se ha interceptado javax.faces.FacesException durante el procesamiento de INVOKE_APPLICATION 5 : UIComponent-ClientId=, Mensaje=java.io.IOException: Stream closed
jul 30, 2015 10:07:33 AM com.sun.faces.context.ExceptionHandlerImpl log
1100: java.io.IOException: Stream closed
javax.faces.FacesException: java.io.IOException: Stream closed
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:89)
   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
   at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
   at alfresco.modelbd.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:52)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
   at java.lang.Thread.run(Thread.java:745)
Caused by: javax.faces.FacesException: java.io.IOException: Stream closed
   at org.primefaces.component.filedownload.FileDownloadActionListener.processAction(FileDownloadActionListener.java:90)
   at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
   at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:813)
   at javax.faces.component.UICommand.broadcast(UICommand.java:300)
   at javax.faces.component.UIData.broadcast(UIData.java:1108)
   at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
   … 26 more
Caused by: java.io.IOException: Stream closed
   at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162)
   at java.io.BufferedInputStream.read(BufferedInputStream.java:325)
   at java.io.FilterInputStream.read(FilterInputStream.java:107)
   at org.primefaces.component.filedownload.FileDownloadActionListener.processAction(FileDownloadActionListener.java:81)
   … 33 more


Dejo la parte del código donde juego a con la descarga del documento:


public void prueba(String id) throws Exception {
      try {
         String prueba = id;
         if (prueba.equals("")) {
            FacesContext.getCurrentInstance().addMessage(
                  null,
                  new FacesMessage(FacesMessage.SEVERITY_INFO, "Info",
                        "Documento de descarga no asociado"));
         } else {
            SesionAlfresco sesionAlfrescoInstaance = new SesionAlfresco();
            session = sesionAlfrescoInstaance.getSesion();
            DocumentoCmis = (Document) session.getObject(prueba);
            in = DocumentoCmis.getContentStream().getStream();
            String tipoMime = DocumentoCmis.getContentStreamMimeType();
            String nombre = DocumentoCmis.getContentStreamFileName();
            fileDownload = new DefaultStreamedContent(in, tipoMime, nombre);
         }
      } catch (Exception e) {
         e.printStackTrace();
      }

   }



Gracias!!
1 REPLY 1

gonial
Champ in-the-making
Champ in-the-making
Pensando que el problema era con alfresco, he comprobado que la solución estaba tratando mejor la variable fileDownload (   private StreamedContent fileDownload; )

Sol:


if (prueba.equals("")) {
             –> fileDownload=null; <–
            FacesContext.getCurrentInstance().addMessage(
                  null,
                  new FacesMessage(FacesMessage.SEVERITY_INFO, "Info",
                        "Documento de descarga no asociado"));
         } else {
            SesionAlfresco sesionAlfrescoInstaance = new SesionAlfresco();
            session = sesionAlfrescoInstaance.getSesion();
            DocumentoCmis = (Document) session.getObject(prueba);
            in = DocumentoCmis.getContentStream().getStream();
            String tipoMime = DocumentoCmis.getContentStreamMimeType();
            String nombre = DocumentoCmis.getContentStreamFileName();
            fileDownload = new DefaultStreamedContent(in, tipoMime, nombre);
                        
         }


Gracias!!