You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/07/29 13:04:40 UTC

[Bug 53613] org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4 exception : this error should NEVER happen

https://issues.apache.org/bugzilla/show_bug.cgi?id=53613

Mark B <ma...@tiscali.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Mark B <ma...@tiscali.co.uk> ---
Not so sure that this is an error but it certainly could be a problem with the
javadoc for the XSSFWorkbook/OPCPackage classes.

Had a quick play with the code this morning and read the full stacktrace
produced when the exception is thrown. The source of the exception is the write
method of the workbook - or one of the methods it calls - and it appears to be
caused by the fact that the OPCPackage is no longer available when the workbook
is being written out. If the call to the close() method of the OPCPackage
instance if moved to follow the write() method of the workbook, then the
exception is not thrown.

So, it seems that if a workbook is cretade from an instance of the OPCPackage
class, the OPCPacakge instance must not be disposed of until after the workbook
has been written. This change the the code, removed the problem completely;

org.apache.poi.openxml4j.opc.OPCPackage opc = 
   org.apache.poi.openxml4j.opc.OPCPackage.open(filename);
org.apache.poi.xssf.usermodel.XSSFWorkbook wb =
   new org.apache.poi.xssf.usermodel.XSSFWorkbook(opc);
java.io.FileOutputStream fileOut = new java.io.FileOutputStream(filename);
wb.write(fileOut);
opc.close();
fileOut.close();  

Perhaps documenting this in the javadoc for the workbook and OPCPackage classes
would be sufficient.

Mark B

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org