Bug 61297 - got this message: this error should NEVER happen while trying to copy rows in Excel
Summary: got this message: this error should NEVER happen while trying to copy rows in...
Status: RESOLVED DUPLICATE of bug 59158
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.16-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2017-07-13 21:50 UTC by Ted Ji
Modified: 2017-07-14 00:12 UTC (History)
0 users

got this message: this error should NEVER happen! (2.40 KB, text/x-csrc)
2017-07-13 21:50 UTC, Ted Ji
Excel file causing problem (14.30 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2017-07-13 22:27 UTC, Ted Ji

Note You need to log in before you can comment on or make changes to this bug.
Description Ted Ji 2017-07-13 21:50:06 UTC
Created attachment 35132 [details]
got this message: this error should NEVER happen!

I was trying to copy some row of data from one part of sheet to another and then save it to another workbook and I got this error. As it said error should NEVER Happen I filed this report. Will see what I did wrong.

start test
number of sheets=1
row= 0 27
row=3 no. cells=11 new= 26
... copy rows
row=4 no. cells=11 new= 27
... copy rows
Exception in thread "main" org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4 exception : this error should NEVER happen! If you can provide the triggering file, then please raise a bug at https://bz.apache.org/bugzilla/enter_bug.cgi?product=POI and attach the file that triggers it, thanks!
	at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.getContentType(ContentTypeManager.java:340)
	at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.removeContentType(ContentTypeManager.java:253)
	at org.apache.poi.openxml4j.opc.OPCPackage.removePart(OPCPackage.java:1020)
	at org.apache.poi.openxml4j.opc.PackagePart.getOutputStream(PackagePart.java:519)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.commit(XSSFWorkbook.java:1826)
	at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:414)
	at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:242)
	at modelbacktest_excel.ModelBackTest_excel.main(ModelBackTest_excel.java:53)
Java Result: 1
Comment 1 PJ Fanning 2017-07-13 22:23:27 UTC
Hi Ted,
Can you attach the Backtesting_template.xlsx file and confirm that you are using poi 3.16?
Comment 2 Ted Ji 2017-07-13 22:27:22 UTC
Created attachment 35133 [details]
Excel file causing problem

I since fixed my typos but here the info.

I am using poi-3.1.6-beta2 and I've attached the Excel file
Comment 3 Javen O'Neal 2017-07-13 23:34:59 UTC
Can you also include the code that produced this error message?

This Rule M2.4 occurs when you try to copy an XML bean from one workbook (DOM) to another.
Comment 4 Javen O'Neal 2017-07-13 23:38:34 UTC
Nevermind. Code is in attachment 35132 [details].

The problem is that you're closing the pkg in a for loop and then closing it again at the exit.

You should only close the OPCPackage once,and after it's closed, the package and anything that relies on the package (such as the XSSFWorkbook) can no longer be used.
Comment 5 Javen O'Neal 2017-07-14 00:12:31 UTC

*** This bug has been marked as a duplicate of bug 59158 ***