title: POI fails to write to excel because DefaultMarshaller
body: <p>The goal is to export a excel file through a REST backend implemented with Jersey, deployed in Payara (Glassfish).</p>
  
  <p>When data exceeds 50 customers I receive an error. POI fails because of DefaultMarshaller.
  Could I exchange the Default Marshaller with a better Marshaller ? Can this be configured in Payara ? </p>
  
  <pre><code>public Response exportCustomers(CustomerFilterRequest filter, String locale) {
  
      List&lt;CustomerEntity&gt; customers = getPagingCustomerEntities(null, filter).getElements();
  
      StreamingOutput streamingOutput = outputStream -&gt; {
          Workbook workBook = new XSSFWorkbook();
          Sheet sheet = workBook.createSheet("Customers");
  
          CellStyle headerCellStyle = workBook.createCellStyle();
          Font font = workBook.createFont();
          font.setBold(true);
          headerCellStyle.setFont(font);
          headerCellStyle.setAlignment(HorizontalAlignment.CENTER);
  
          CellStyle dataCellStyle = workBook.createCellStyle();
          font = workBook.createFont();
          dataCellStyle.setFont(font);
          dataCellStyle.setAlignment(HorizontalAlignment.CENTER);
  
          ExportTable exportTable = new ExportTable(sheet, HEADER, headerCellStyle, dataCellStyle);
  
  
          for (int i = 0; i &lt; customers.size(); i++) {
              CustomerEntity customer = customers.get(i);
              exportTable.createDataRow();
  
              exportTable.addData(customer.getId());
              exportTable.addData(customer.getLastName());
              exportTable.addData(customer.getFirstName());
          }
  
          ExportUtils.autoResizeColumns(sheet);
          **workBook.write(outputStream);** . -----&gt; LINE THAT FAILS 
      };
  
      return Response.ok(streamingOutput, FileType.XLSX.toMimeType()).build();
  }
  
  
  private Sheet sheet;
  private Row row;
  private Cell cell;
  private CellStyle dataCellStyle;
  private String[] headers;
  private int rowIndex = 0;
  private int columnIndex = 0;
  
  public ExportTable(Sheet sheet, String[] headerColumns, CellStyle headerCellStyle, CellStyle dataCellStyle) {
      this.sheet = sheet;
      headers = headerColumns;
      this.dataCellStyle = dataCellStyle;
      row = sheet.createRow(rowIndex++);
      for (int i = 0; i &lt; headers.length; i++) {
          cell = row.createCell(i);
          cell.setCellValue(headers[i]);
          cell.setCellStyle(headerCellStyle);
      }
  }
  
  public void createDataRow() {
      columnIndex = 0;
      row = sheet.createRow(rowIndex++);
  }
  
  public void addData(String value) {
      cell = row.createCell(columnIndex++);
      cell.setCellType(CellType.STRING);
      cell.setCellValue(value);
      cell.setCellStyle(dataCellStyle);
  }
  
  public void addData(Integer value) {
      cell = row.createCell(columnIndex++);
      cell.setCellType(CellType.NUMERIC);
      cell.setCellValue(value);
      cell.setCellStyle(dataCellStyle);
  }
  
  public void createEmptyCell() {
      cell = row.createCell(columnIndex++);
      cell.setCellType(CellType.BLANK);
      cell.setCellStyle(dataCellStyle);
  }
  </code></pre>
  
  <p>Stacktrace: </p>
  
  <pre><code>      [2018-10-18T13:18:09.415+0000] [Payara 4.1] [SEVERE] [] [org.glassfish.jersey.server.ServerRuntime$Responder] [tid: _ThreadID=44 _ThreadName=http-thread-pool::http-listener-2(4)] [timeMillis: 1539868689415] [levelValue: 1000] [[
        An I/O error has occurred while writing a response message entity to the container output stream.
      org.glassfish.jersey.server.internal.process.MappableException: org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to save: an error occurs while saving the package : The part /xl/worksheets/sheet1.xml failed to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.DefaultMarshaller@4ecabb27
          at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:92)
          at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
          at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130)
          at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:711)
          at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:444)
          at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:434)
          at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:329)
          at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
          at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
          at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
          at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
          at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
          at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
          at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
          at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
          at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)     at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)     at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:654)
          at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:598)
          at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
          at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
          at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:483)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
          at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
          at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
          at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
          at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
          at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
          at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
          at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
          at java.lang.Thread.run(Thread.java:748)
      Caused by: org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to save: an error occurs while saving the package : The part /xl/worksheets/sheet1.xml failed to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.DefaultMarshaller@4ecabb27     at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:595)
          at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1539)
          at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:227)
          at
      com.bmwgroup.sfm.conf.GzipWriterInterceptor.aroundWriteTo(GzipWriterInterceptor.java:35)
          at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
          at com.bmwgroup.sfm.security.ClientEncryptionInterceptor.aroundWriteTo(ClientEncryptionInterceptor.java:230)
          at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
          at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106)
          at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
          at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86)
          ... 47 more
      Caused by: org.apache.poi.openxml4j.exceptions.OpenXML4JException: The part /xl/worksheets/sheet1.xml failed to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.DefaultMarshaller@4ecabb27
          at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:586)
          ... 62 more
      ]] 
  </code></pre>
  
  <p>LE </p>
  
  <pre><code>[2018-10-22T08:13:51.703+0000] [Payara 4.1] [SEVERE] [] [org.apache.poi.openxml4j.opc.internal.marshallers.ZipPartMarshaller] [tid: ThreadID=43 ThreadName=http-thread-pool::http-listener-2(2)] [timeMillis: 1540196031703] [levelValue: 1000] [[
  Cannot write: /xl/worksheets/sheet1.xml: in ZIP
  java.io.IOException: Connection is closed
  at org.glassfish.grizzly.nio.NIOConnection.assertOpen(NIOConnection.java:445)
  at org.glassfish.grizzly.http.io.OutputBuffer.write(OutputBuffer.java:677)
  at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
  at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
  at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
  at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
  at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
  at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
  at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
  at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
  at java.lang.Thread.run(Thread.java:748)
  Caused by: java.io.IOException: Broken pipe
  at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
  at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
  at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
  at sun.nio.ch.IOUtil.write(IOUtil.java:51)
  at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
  at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
  at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
  at org.glassfish.grizzly.filterchain.FilterChainContext.write(FilterChainContext.java:890)
  at org.glassfish.grizzly.ssl.SSLBaseFilter.handleWrite(SSLBaseFilter.java:395)
  at org.glassfish.grizzly.filterchain.ExecutorResolver$8.execute(ExecutorResolver.java:111)
  at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
  at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
  at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
  at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
  at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
  at org.glassfish.grizzly.filterchain.FilterChainContext.write(FilterChainContext.java:890)
  at org.glassfish.grizzly.filterchain.FilterChainContext.write(FilterChainContext.java:858)
  at org.glassfish.grizzly.http.io.OutputBuffer.flushBuffer(OutputBuffer.java:1060)
  at org.glassfish.grizzly.http.io.OutputBuffer.flushBinaryBuffers(OutputBuffer.java:1047)
  at org.glassfish.grizzly.http.io.OutputBuffer.flushAllBuffers(OutputBuffer.java:1017)
  at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:139)
  at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:98)
  at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:684)
  at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:728)
  at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:343)
  at org.apache.poi.openxml4j.opc.StreamHelper.saveXmlInStream(StreamHelper.java:84)
  at org.apache.poi.openxml4j.opc.internal.marshallers.ZipPartMarshaller.marshallRelationshipPart(ZipPartMarshaller.java:180)
  at org.apache.poi.openxml4j.opc.internal.marshallers.ZipPartMarshaller.marshall(ZipPartMarshaller.java:104)
  ... 65 more
  ]]
  
  [2018-10-22T08:13:51.704+0000] [Payara 4.1] [SEVERE] [] [org.glassfish.jersey.server.ServerRuntime$Responder] [tid: ThreadID=43 ThreadName=http-thread-pool::http-listener-2(2)] [timeMillis: 1540196031704] [levelValue: 1000] [[
  An I/O error has occurred while writing a response message entity to the container output stream.
  org.glassfish.jersey.server.internal.process.MappableException: org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to save: an error occurs while saving the package : The part /xl/worksheets/sheet1.xml failed to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.DefaultMarshaller@5cea6d26
  at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:92)
  at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
  at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130)
  at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:711)
  at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
  at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
  at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
  at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
  at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
  at java.lang.Thread.run(Thread.java:748)
  Caused by: org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to save: an error occurs while saving the package : The part /xl/worksheets/sheet1.xml failed to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.DefaultMarshaller@5cea6d26
  at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:595)
  at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1539)
  at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:227)
  at org.glassfish.jersey.message.internal.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:78)
  at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
  at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106)
  at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
  at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86)
  ... 47 more
  Caused by: org.apache.poi.openxml4j.exceptions.OpenXML4JException: The part /xl/worksheets/sheet1.xml failed to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.DefaultMarshaller@5cea6d26
  at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:586)
  ... 62 more
  ]]
  </code></pre>