0

I tried to generate word(.doc) file by using org.apache.poi and spring mvc. But there was an error occurred:

jetty ErrorLogMappingExceptionResolver Closed java.io.IOException: Closed")

when controller returned, and the word(.doc) file could export successfully.

This exception is in org.eclipse.jetty.server.HttpOutput.write() after file has generated, and jetty invoked HttpOutput.write again lead to excepiton?

related code:

HttpServletResponse response;
OutputStream outputStream = response.getOutputStream();

XWPFDocument xWPFDocument = new XWPFDocument();
xWPFDocument.write(outputStream);

outputStream.flush();
outputStream.close();

error log :

jetty ErrorLogMappingExceptionResolver Closed java.io.IOException: Closed
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:140) ~[jetty-all-8.1.10.v20130312.jar:8.1.10.v20130312]
    at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:107) ~[jetty-all-8.1.10.v20130312.jar:8.1.10.v20130312]
    at com.opensymphony.module.sitemesh.filter.RoutableServletOutputStream.write(RoutableServletOutputStream.java:118) ~[sitemesh-2.4.2.jar:?]
    at com.fasterxml.jackson.core.json.UTF8JsonGenerator._flushBuffer(UTF8JsonGenerator.java:2085) ~[jackson-core-2.9.3.jar:2.9.3]
    at com.fasterxml.jackson.core.json.UTF8JsonGenerator.flush(UTF8JsonGenerator.java:1097) ~[jackson-core-2.9.3.jar:2.9.3]
    at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:915) ~[jackson-databind-2.9.3.jar:2.9.3]

user207421
  • 305,947
  • 44
  • 307
  • 483
  • 1
    Don't call `flush()` or `close()`. Obviously `XWPDFDocument.write()` closes the stream. In any case `close()` implies `flush()`. – user207421 May 08 '19 at 08:44
  • 1
    [Jetty 8 is EOL (End of Life)](https://www.eclipse.org/lists/jetty-announce/msg00069.html) as of [November 2014](https://www.eclipse.org/jetty/documentation/current/what-jetty-version.html). Please consider upgrading to something stable and supported. – Joakim Erdfelt May 08 '19 at 09:20
  • @JoakimErdfelt That doesn't make it part of the question, or explain the error. – user207421 May 08 '19 at 10:03
  • 1
    No Jetty specific answer as that version is far too old, even the developers of Jetty don't know how that version works anymore ... but here's a prior Answer with some details about Servlet outputstream close behavior (which @user207421 hinted about) - https://stackoverflow.com/a/1159244/775715 – Joakim Erdfelt May 08 '19 at 10:19
  • @JoakimErdfelt No 'Jetty-specific answer' is required. Read my first comment. An *answer* to this question *might* involve end-of-life, although it doesn't, but that doesn't mean the *question* is about end-of-life, which in turn doesn't justify adding [tag:end-of-life] to the tags. `ServletOutputStream` doesn't have anything to do with it. – user207421 May 08 '19 at 11:08
  • Behavior on Jetty is often a focus on theses styles of questions. The fact that the OP is using Jetty 8.1 puts him 6 major version releases of Jetty behind stable/supported. Behavior on Jetty cannot be answered anymore on this old of a Jetty release. – Joakim Erdfelt May 08 '19 at 14:32
  • @JoakimErdfelt The problem is the `flush()`. See the stack trace. Don't add irrelevant tags. He didn't ask about [tag:end-of-life]. – user207421 May 08 '19 at 23:07

0 Answers0