Bug 59159 - Exception in thread "main" org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4 exception : this error should NEVER happen! Please raise a bug at *this site* and attach a file that triggers
Summary: Exception in thread "main" org.apache.poi.openxml4j.exceptions.OpenXML4JRunti...
Status: RESOLVED DUPLICATE of bug 59158
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.13-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-10 01:03 UTC by Stefan
Modified: 2016-03-11 22:36 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan 2016-03-10 01:03:19 UTC
I got the message : Exception in thread "main" org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4 exception : this error should NEVER happen! Please raise a bug at https://bz.apache.org/bugzilla/enter_bug.cgi?product=POI and attach a file that triggers it, thanks!
	at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.getContentType(ContentTypeManager.java:343)
	at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.removeContentType(ContentTypeManager.java:256)
	at org.apache.poi.openxml4j.opc.OPCPackage.removePart(OPCPackage.java:943)
	at org.apache.poi.openxml4j.opc.PackagePart.getOutputStream(PackagePart.java:522)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.commit(XSSFWorkbook.java:1678)
	at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:341)
	at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:206)

Since the file that triggers it is fairly big I'm attaching the code that triggers it.
This code is the very beginning, the only lines before it are declarations and initializations. Written in Java 8 u 74. Good luck ! :)

for(String folder : godine){
            XSSFWorkbook wbTemp = new XSSFWorkbook();
            wbTemp.createSheet();
            FileOutputStream fo = new FileOutputStream(lokacijaResursa+"\\statistika-"+folder+".xlsx");
            HashMap<String,Integer> pozicija = new HashMap<>();
            napraviCelije(wbTemp,100,200);
            for(int i=1;i<=12;i++) {
                try {
                    XSSFWorkbook mjesec = new XSSFWorkbook(new FileInputStream(new File(lokacijaResursa + "\\" + folder + "\\" + i + ".xlsx")));
                    XSSFSheet sheetMjesec = mjesec.getSheetAt(0);
                    popuni(wbTemp, mjesec, pozicija, i);
                }
                catch (Exception ex){}
            }
            wbTemp.write(fo);
            fo.close();
            XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(lokacijaResursa+"\\statistika-"+folder+".xlsx"));
            int numOfCells = 0;
            try{
                for(int i=3;;i++){
                    Row r = wb.getSheetAt(0).getRow(1);
                    Cell c = r.getCell(i,Row.CREATE_NULL_AS_BLANK);
                    if(c.getCellType() == Cell.CELL_TYPE_BLANK)
                        break;
                    numOfCells++;
                }
                for(int i=2;;i++){
                    Row r = wb.getSheetAt(0).getRow(i);
                    if(r.getCell(0,Row.CREATE_NULL_AS_BLANK).getCellType() == Cell.CELL_TYPE_BLANK)
                        break;
                    for(int j=3;j<numOfCells;j++){
                        Cell c = r.getCell(j,Row.CREATE_NULL_AS_BLANK);
                        if(c.getCellType() == Cell.CELL_TYPE_BLANK)
                            break;
                        else c.setCellValue(0);
                    }
                }
            }
            catch (NullPointerException ex){
                System.out.println("Nema fajlova");
                System.exit(0);
            }
            wb.close();
            fo = new FileOutputStream(new File(lokacijaResursa+"\\statistika-"+folder+".xlsx"));
            wb.write(fo);
            fo.close();
        }
Comment 1 Dominik Stadler 2016-03-11 22:36:21 UTC
Duplicate of bug 59159 as far as I see, please reopen with description why it should be handled separatedely if this is not the case.

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