我在我的控制器中有这个方法。 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)
我已经阅读了很多关于这个问题,但没有一个解决方案帮助了我。所以,如果我做错了,或者只是我想要达到的这种行为是不可能的,我有点困惑。
答案 0 :(得分:2)
response.outputStream << pdf;
此代码会自动刷新您的回复,因此无需在之后添加close()
。将您的代码更改为:
def getUserInvoiceImage (GetInvoiceDataCommand form) {
byte[] pdf = invoiceImageService.getUserInvoiceImage(form.invoiceId)
response.setContentType('application/pdf')
response.outputStream << pdf;
}
答案 1 :(得分:1)
我认为您的面板正在使用ajax请求获取pdf,当面板崩溃并再次展开ajax请求时。
答案 2 :(得分:0)
这表示找不到文件
您致电flush
了解该邮件未被抛出的原因。
注释说明包括flush
调用以查看错误消息。
如果是,请管理您的文件,取消注释flush
来电。