gpt4 book ai didi

org.apache.coyote.tomcat5.CoyoteResponseFacade.setBufferSize 处的 java.lang.IllegalStateException

转载 作者:行者123 更新时间:2023-12-02 06:06:50 26 4
gpt4 key购买 nike

我有一个使用 JSF 2.0.2 在 Glassfish 服务器上运行的 Java 应用程序。

在 JSF 级别,我有以下方法调用。

<h:commandLink action="#{printWB.doOpenVehicleToPrintInPDF}" target="_blank">Print</h:commandLink>

我的方法doOpenVehicleToPrintInPDF定义如下:

public String doOpenVehicleToPrintInPDF() {
FacesContext ctxt = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) ctxt.getExternalContext().getResponse();

try {
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "attachment; filename=\"" + configUrl + ".pdf\"");

final ServletOutputStream stream = response.getOutputStream();

final VehiclePrintSummaryToPdf vehiclePrintPdf = new VehiclePrintSummaryToPdf(ctxt, summary);
vehiclePrintPdf.createPdfDocument(stream, summary);
stream.flush();
Validate.isTrue(response.isCommitted());
stream.close();
} catch (Exception ex) {
LOG.error("Error in PDF print processing!", ex);
}
return null;
}

调用该方法,生成 PDF(使用 itext 库),然后抛出以下异常。我已经对此进行了调试,异常发生在 return null;

之后

任何提示这里出了什么问题以及如何避免此异常?

提前致谢。

java.lang.IllegalStateException
at org.apache.coyote.tomcat5.CoyoteResponseFacade.setBufferSize(CoyoteResponseFacade.java:260)
at com.sun.faces.context.ExternalContextImpl.setResponseBufferSize(ExternalContextImpl.java:795)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.createResponseWriter(FaceletViewHandlingSt
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.jav
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at com.bmw.codis.ncc.web.entrypoint.EntryServletFilterNCC.doFilter(EntryServletFilterNCC.java:98)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:599)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:92)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:34
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)

最佳答案

JSF 生命周期试图在其渲染阶段写入一个关闭的流。为防止这种情况,您必须调用 responseComplete()FacesContext 上。

关于org.apache.coyote.tomcat5.CoyoteResponseFacade.setBufferSize 处的 java.lang.IllegalStateException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8414349/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com