读取bean上的Stream时出错

时间:2017-03-31 15:20:37

标签: jsf stream

我试图使用streamedcontenct查看PDF但我仍然收到此错误。

31-Mar-2017 10:26:32.796 INFORMACIÓN [http-apr-8080-exec-78] com.sun.faces.context.ExceptionHandlerImpl.throwIt Exception when handling error trying to reset the response.
 java.io.IOException: javax.el.ELException: /ordenRetiro.xhtml @211,112 value="#{ordenRetiroBean.stream}": Error reading 'stream' en el tipo com.delpac.bean.OrdenRetiroBean
    at org.primefaces.component.media.MediaRenderer.encodeEnd(MediaRenderer.java:45)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:85)
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:72)
    at org.primefaces.component.dialog.DialogRenderer.encodeContent(DialogRenderer.java:186)
    at org.primefaces.component.dialog.DialogRenderer.encodeMarkup(DialogRenderer.java:115)
    at org.primefaces.component.dialog.DialogRenderer.encodeEnd(DialogRenderer.java:47)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:89)
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:72)
    at org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:206)
    at org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:123)
    at org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:58)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:78)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:509)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1104)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2508)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2497)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: javax.el.ELException: /ordenRetiro.xhtml @211,112 value="#{ordenRetiroBean.stream}": Error reading 'stream' en el tipo com.delpac.bean.OrdenRetiroBean
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
    at org.primefaces.component.media.Media.getValue(Media.java:77)
    at org.primefaces.component.media.MediaRenderer.getMediaSrc(MediaRenderer.java:126)
    at org.primefaces.component.media.MediaRenderer.encodeEnd(MediaRenderer.java:43)
    ... 49 more
Caused by: javax.el.ELException: Error reading 'stream' en el tipo com.delpac.bean.OrdenRetiroBean
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:101)
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
    ... 53 more
Caused by: java.io.FileNotFoundException: nullnull (El sistema no puede encontrar el archivo especificado)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at com.delpac.bean.OrdenRetiroBean.getStream(OrdenRetiroBean.java:511)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:97)
    ... 58 more

我的xhtml是这样的: 命令链接打开p:对话框

<p:column  style="text-align: center">
  <p:commandLink ajax="true" id="icon-pdf" class="icon-edit" value="" 
  actionListener="#{ordenRetiroBean.showPDFDialog(ord)}" 
  oncomplete="PF('dlgReporte').show();" update="DialogPDF" />
</p:column>

p:对话框代码:

<p:dialog id="DialogPDF" widgetVar="dlgReporte" modal="true" closable="true" 
          closeOnEscape="true" width="900" height="350" header="Orden de Retiro">
   <h:form>
        <p:media value="#{ordenRetiroBean.stream}" height="600" width="600" player="pdf" />
   </h:form>
</p:dialog>

我的豆子: 在构造函数上:

exportDir = System.getProperty("catalina.base") + "\\OrdenesRetiro\\"; 
nom_archivo = "Orden_de_Retiro" + ord.getCod_ordenretiro() + ".pdf";
nom_archivo_sinext = "Orden_de_Retiro" + ord.getCod_ordenretiro();

我宣布了一个StreamedContent变量calle&#34; stream&#34;,所以在getter我设置了这个:

public StreamedContent getStream() throws IOException{
        return new DefaultStreamedContent(new FileInputStream(new File(exportDir + nom_archivo)), "application/pdf", nom_archivo_sinext);
}

随时询问您是否需要更多信息。我需要在一个数据表上显示它将要使用commandlink按钮的每一行,所以当用户点击它时,它会显示一个p:对话框,里面有PDF。

0 个答案:

没有答案