2

我的控制器中有这个方法。Whick 基本上呈现 pdf 文件。

    def getUserInvoiceImage (GetInvoiceDataCommand form) {
        byte[] pdf = invoiceImageService.getUserInvoiceImage(form.invoiceId)
        response.setContentType('application/pdf')
        response.outputStream << pdf;
        response.outputStream.close()
        return false;
    }

当我双击它时,它工作正常。但是当我折叠并展开我的面板时,会发生以下异常。

    Software caused connection abort: socket write error. Stacktrace follows:
java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
    at net.bull.javamelody.FilterServletOutputStream.write(FilterServletOutputStream.java:64)
    at net.bull.javamelody.CounterResponseStream.write(CounterResponseStream.java:75)
    at com.tieto.msi.InvoiceImageController.getUserInvoiceImage(InvoiceImageController.groovy:13)
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
    at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
    at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
2013-08-19 12:43:15,636 ERROR KULDARIM org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver: IllegalStateException occurred when processing request: [GET] /MySupplierInvoices/invoiceImage/getUserInvoiceImage - parameters:
invoiceId: 5274216
getOutputStream() has already been called for this response. Stacktrace follows:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
    at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
    at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response
    at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
    at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
    ... 10 more
2013-08-19 12:43:15,639 WARN   grails.plugin.cache.web.filter.simple.MemoryPageFragmentCachingFilter: Throwable thrown during doFilter on request with URI: /MySupplierInvoices/grails/invoiceImage/getUserInvoiceImage.dispatch and Query: invoiceId=5274216 : Request processing failed; nested exception is org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
    at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
    at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
    ... 10 more
Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response
    at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
    at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
    ... 10 more
2013-08-19 12:43:15,640 ERROR  org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/MySupplierInvoices].[grails]: Servlet.service() for servlet grails threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
    at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
    at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
    at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
    at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
2013-08-19 12:43:15,642 ERROR  org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/MySupplierInvoices].[default]: Servlet.service() for servlet [default] in context with path [/MySupplierInvoices] threw exception [org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response] with root cause
java.lang.IllegalStateException: getOutputStream() has already been called for this response
    at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
    at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
    at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
    at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)

我已经阅读了很多关于这个问题的内容,但没有一个解决方案对我有帮助。所以如果我做错了什么或者我想要达到的这种行为是不可能的,我会有点困惑。

4

3 回答 3

2
response.outputStream << pdf;

此代码将自动刷新您的响应,因此无需在close()之后添加。将您的代码更改为:

def getUserInvoiceImage (GetInvoiceDataCommand form) {
    byte[] pdf = invoiceImageService.getUserInvoiceImage(form.invoiceId)
    response.setContentType('application/pdf')
    response.outputStream << pdf;
}
于 2013-08-19T12:16:26.660 回答
1

我认为您的面板正在使用 ajax 请求来获取 pdf,当面板折叠并展开 ajax 请求时再次发生。

另请参阅此问题和答案

于 2013-08-19T10:03:12.987 回答
0
  • 这意味着找不到您的文件

  • 你打电话flush这就是为什么该消息没有抛出。

  • 注释指令包括flush调用以查看错误消息。

  • 如果是这样,那么管理您的文件存在,取消注释flush调用。

于 2015-01-23T07:44:05.673 回答