Bug 61703 - Fail to save stream with OpenXML4JRuntimeException
Summary: Fail to save stream with OpenXML4JRuntimeException
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 3.15-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-31 11:09 UTC by kumai
Modified: 2017-12-27 21:27 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kumai 2017-10-31 11:09:48 UTC
Hi Team,

Although the reproduction procedure is unknown, Excel export fails with the following exception being output. 

2017-10-27 21:23:21,867 Caesium-1-4 INFO ServiceRunner     [c.a.j.p.h.service.connect.InstallGlancesJobHandler] There is no link to HipChat, no need to install glances.
2017-10-27 21:34:48,669 http-nio-8081-exec-17 ERROR      [o.a.c.c.C.[.[localhost].[/jira].[default]] Servlet.service() for servlet [default] in context with path [/jira] threw exception
org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to save: an error occurs while saving the package : The part /docProps/core.xml fail to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller@5c5d22d0
        at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:602)
        at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1557)
        at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:248)
        at jp.ricksoft.plugins.wbsgantt_excel.xl.XLSXGenerator.writeTo(XLSXGenerator.kt:45)
        at jp.ricksoft.plugins.wbsgantt.export.XLSXWriter.writeTo(XLSXWriter.kt:25)
        at jp.ricksoft.plugins.wbsgantt.export.XLSXWriter.writeTo(XLSXWriter.kt:15)
        at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:302)
        ... 5 filtered
        at com.atlassian.plugins.rest.module.RestDelegatingServletFilter$JerseyOsgiServletContainer.doFilter(RestDelegatingServletFilter.java:154)
        ... 1 filtered
        at com.atlassian.plugins.rest.module.RestDelegatingServletFilter.doFilter(RestDelegatingServletFilter.java:68)
        ... 33 filtered
        at com.atlassian.servicedesk.internal.web.OperationalStatusAwareHttpFilter.doFilter(OperationalStatusAwareHttpFilter.java:31)
        ... 8 filtered
        at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
        ... 53 filtered
        at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:76)
        at com.atlassian.jira.security.JiraSecurityFilter$$Lambda$655/1940324629.doFilter(Unknown Source)
        ... 1 filtered
        at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:74)
        ... 16 filtered
        at com.atlassian.plugins.rest.module.servlet.RestSeraphFilter.doFilter(RestSeraphFilter.java:37)
        ... 20 filtered
        at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30)
        ... 5 filtered
        at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.lambda$invokeFilterChain$0(CustomerContextSettingFilter.java:181)
        at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter$$Lambda$1021/1377745274.call(Unknown Source)
        at com.atlassian.servicedesk.internal.utils.context.ReentrantThreadLocalBasedCodeContext.rteInvoke(ReentrantThreadLocalBasedCodeContext.java:142)
        at com.atlassian.servicedesk.internal.utils.context.ReentrantThreadLocalBasedCodeContext.runOutOfContext(ReentrantThreadLocalBasedCodeContext.java:94)
        at com.atlassian.servicedesk.internal.utils.context.CustomerContextServiceImpl.runOutOfCustomerContext(CustomerContextServiceImpl.java:64)
        at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.outOfCustomerContext(CustomerContextSettingFilter.java:174)
        at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilterImpl(CustomerContextSettingFilter.java:130)
        at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilter(CustomerContextSettingFilter.java:121)
        ... 4 filtered
        at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:32)
        ... 8 filtered
        at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
        ... 4 filtered
        at com.atlassian.web.servlet.plugin.LocationCleanerFilter.doFilter(LocationCleanerFilter.java:36)
        ... 29 filtered
        at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
        ... 27 filtered
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.poi.openxml4j.exceptions.OpenXML4JException: The part /docProps/core.xml fail to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller@5c5d22d0
        at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:582)
        ... 245 more
2017-10-27 22:23:19,293 Caesium-1-3 INFO ServiceRunner     [c.a.j.p.h.service.ping.RefreshConnectionStatusJobHandler] Running RefreshConnectionStatusJobHandler...


Apache POI 3.15
Server version: Apache Tomcat/8.0.38
Server built:   Oct 6 2016 20:51:55 UTC
Server number:  8.0.38.0
OS Name:        Linux
OS Version:     2.6.32-358.el6.x86_64
Architecture:   amd64
JVM Version:    1.8.0_25-b17
JVM Vendor:     Oracle Corporation


I found the following bug report, but I do not know how to reproduce it in detail or how to handle it, so please let me know.

http://apache-poi.1045710.n5.nabble.com/Fail-to-save-stream-td5723711.html

Best regards,
Ryosuke Kumai
Comment 1 Javen O'Neal 2017-10-31 11:28:00 UTC
Relevant portions of the stack trace:
> org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to save: an
> error occurs while saving the package : The part /docProps/core.xml fail to be 
> saved in the stream with marshaller 
> org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller@5c5d22d0
>         at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:602)
>         at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1557)
>         at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:248)
> 
> Caused by: org.apache.poi.openxml4j.exceptions.OpenXML4JException: The part
> /docProps/core.xml fail to be saved in the stream with marshaller 
> org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller@5c5d22d0
>         at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:582)
>         ... 245 more

From the stack trace, this error occurred while saving an OOXML file.

(In reply to Andrei Ivanov from POI Users mailing list)
> I have a hunch that the http request just gets aborted/reset so the
> output stream just gets closed. 

> I'll probably wait for the next release to include it in our next
> release and then I'll follow the logs.

Have you looked into either of these?
Are you able to check if your output stream is getting closed before POI can finish writing to it?
Do you have any logs to indicate what is happening on this platform?
Is this repeatable?
How many times are you writing out the workbook?
Are you able to write out the workbook to a ByteArrayOutputStream and then write that BAOS to the desired OutputStream? This would help you figure out if the problem is with POI or with the output stream getting closed unexpectedly.

class XLSXGenerator {
    void writeTo(XSSFWorkbook workbook, OutputStream out) {
        try (OutputStream baos = new ByteArrayOutputStream(8192)) {
            try {
                workbook.write(baos);
            } finally {
                workbook.close();
            }
            baos.writeTo(out);
        }
    }
}
Comment 2 Dominik Stadler 2017-12-27 21:27:06 UTC
Couldn't reproduce and no answer to questions for some time, thus closing this as WORKSFORME for now, please reopen with more information if this is still a problem for you.

I also reviewed the code and did not see any exception swallowing taking place, so as far as I see the exception handling already provides everything that we can on the side of the library.