[Bug 61575] New: OpenXML4JRuntimeException when closing OPCPackage

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 61575] New: OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

            Bug ID: 61575
           Summary: OpenXML4JRuntimeException when closing OPCPackage
           Product: POI
           Version: 3.16-FINAL
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: OPC
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

Created attachment 35388
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35388&action=edit
Source and example files

The docx file contains an image causing this exception. It does not happen for
any other image in my actual document. Removing the graphic will work just fine
with the attached test code.


Error Message:

rg.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to save: an
error occurs while saving the package : The part /word/media/image1.wmf failed
to be saved in the stream with marshaller
org.apache.poi.openxml4j.opc.internal.marshallers.DefaultMarshaller@4b85612c
        at
org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:595)
        at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1543)
        at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1526)
        at
org.apache.poi.openxml4j.opc.ZipPackage.closeImpl(ZipPackage.java:450)
        at org.apache.poi.openxml4j.opc.OPCPackage.close(OPCPackage.java:479)
        at
com.sovelia.office.DocxMetadataWriter.setDocxMetadata(DocxMetadataWriter.java:29)
        at
com.sovelia.office.DocxMetadataWriter.main(DocxMetadataWriter.java:12)
Caused by: org.apache.poi.openxml4j.exceptions.OpenXML4JException: The part
/word/media/image1.wmf failed to be saved in the stream with marshaller
org.apache.poi.openxml4j.opc.internal.marshallers.DefaultMarshaller@4b85612c
        at
org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:586)
        ... 6 more

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61575] OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

azad <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61575] OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

--- Comment #1 from azad <[hidden email]> ---
However, after the exception thrown and the source docx file is corrupted.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61575] OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

--- Comment #2 from azad <[hidden email]> ---
different way to write coreproperties also provided exception a bit
differently. Use same test file in attachment. First time it is successfully
read/writes and second time gives the exception.

Code:
try {
            InputStream fis = new FileInputStream(fileName);
            XWPFDocument doc = new XWPFDocument(fis);

            CoreProperties cp = doc.getProperties().getCoreProperties();
            cp.setCreator("Test Creator");

            OutputStream fos = new FileOutputStream(fileName);
            doc.write(fos);
            doc.close();
            fos.close();
            fis.close();
        }catch(Exception e){e.printStackTrace();}


Exception:


java.io.IOException: Failed to read zip entry source
        at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:103)
        at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:324)
        at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
        at
org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:116)
        at com.sovelia.office.Test.testDocxReadWrite(Test.java:127)
        at com.sovelia.office.Test.main(Test.java:31)
Caused by: java.io.IOException: Zip bomb detected! The file would exceed the
max. ratio of compressed file size to the size of the expanded data. This may
indicate that the file is used to inflate memory usage and thus could pose a
security risk. You can adjust this limit via ZipSecureFile.setMinInflateRatio()
if you need to work with files which exceed this limit. Counter: 1326240,
cis.counter: 13253, ratio: 0.009992912293400893Limits: MIN_INFLATE_RATIO: 0.01
        at
org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream.advance(ZipSecureFile.java:266)
        at
org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream.read(ZipSecureFile.java:221)
        at java.io.FilterInputStream.read(FilterInputStream.java:107)
        at
org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource$FakeZipEntry.<init>(ZipInputStreamZipEntrySource.java:132)
        at
org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.<init>(ZipInputStreamZipEntrySource.java:56)
        at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:100)
        ... 5 more

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61575] OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

PJ Fanning <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|blocker                     |normal
         Depends on|                            |61564


Referenced Bugs:

https://bz.apache.org/bugzilla/show_bug.cgi?id=61564
[Bug 61564] Illegal reflective access by org.apache.poi.util.DocumentHelper in
Java 9
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61575] OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

--- Comment #3 from PJ Fanning <[hidden email]> ---
Java 9 is just out and it looks we have a few issues (eg
https://bz.apache.org/bugzilla/show_bug.cgi?id=61564)

There is a plan to issue a 3.17.1 patch to fix issues when Java 9 is used.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61575] OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

PJ Fanning <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|61564                       |


Referenced Bugs:

https://bz.apache.org/bugzilla/show_bug.cgi?id=61564
[Bug 61564] Illegal reflective access by org.apache.poi.util.DocumentHelper in
Java 9
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61575] OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

--- Comment #4 from PJ Fanning <[hidden email]> ---
Apologies for the confusion. I put the Java 9 comment on the wrong issue.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61575] OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

--- Comment #5 from PJ Fanning <[hidden email]> ---
What happens when you adjust ZipSecureFile.setMinInflateRatio() as the error
message suggests?

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61575] OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

--- Comment #6 from azad <[hidden email]> ---
(In reply to PJ Fanning from comment #5)
> What happens when you adjust ZipSecureFile.setMinInflateRatio() as the error
> message suggests?

Hi Fanning,
Thanks, it works with the ZipSecureFile.setMinInflateRatio().

However, just to mention that my first example did not provide this proper
error message about Minimum Inflate Ratio.

-a-

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61575] OpenXML4JRuntimeException when closing OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61575

Dominik Stadler <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|NEW                         |RESOLVED

--- Comment #7 from Dominik Stadler <[hidden email]> ---
The exception is thrown in your original case as well, but sent as log-line to
the configured POILogger internally.

The default logger is not sending any output to keep the lib from spamming
stdout, but you can easily define a different one, e.g. by specifying
-Dorg.apache.poi.util.POILogger=org.apache.poi.util.SystemOutLogger

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]