[Bug 59158] New: Error when trying to read/write the same excel multiple times (no parallel reads or writes )

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Bug 59158] New: Error when trying to read/write the same excel multiple times (no parallel reads or writes )

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

            Bug ID: 59158
           Summary: Error when trying to read/write the same excel
                    multiple times (no parallel reads or writes )
           Product: POI
           Version: 3.13-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: [hidden email]
          Reporter: [hidden email]

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();
        }

--
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
|  
Report Content as Inappropriate

[Bug 59158] OpenXML4JRuntimeException: Rule M2.4 exception

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

Stefan <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
            Summary|Error when trying to        |this error should NEVER
                   |read/write the same excel   |happen! Please raise a bug
                   |multiple times (no parallel |at
                   |reads or writes )           |https://bz.apache.org/bugzi
                   |                            |lla/enter_bug.cgi?product=P
                   |                            |OI and attach a file that
                   |                            |triggers it, thanks!
            Summary|this error should NEVER     |this error should NEVER
                   |happen! Please raise a bug  |happen! Please raise a bug
                   |at                          |at *link* and attach a file
                   |https://bz.apache.org/bugzi |that triggers it, thanks!
                   |lla/enter_bug.cgi?product=P |
                   |OI and attach a file that   |
                   |triggers it, thanks!        |

Dominik Stadler <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO
             Status|NEEDINFO                    |NEW
            Summary|this error should NEVER     |OpenXML4JRuntimeException:
                   |happen! Please raise a bug  |Rule M2.4 exception
                   |at *link* and attach a file |
                   |that triggers it, thanks!   |
             Status|NEW                         |NEEDINFO

--- Comment #1 from Dominik Stadler <[hidden email]> ---
What about the "and attach a file that triggers it" in the error message?
Without a sample file that triggers the error, it is hard to say if the file is
simply malformed or POI does not read the format correctly here.

--- Comment #2 from Dominik Stadler <[hidden email]> ---
Oops, sorry, just saw the additional part in the description.

--- Comment #3 from Dominik Stadler <[hidden email]> ---
*** Bug 59159 has been marked as a duplicate of this bug. ***

--- Comment #4 from Dominik Stadler <[hidden email]> ---
I did a short review of this report, the provided code still depends on the
actual input-files, so we cannot really reproduce this without some sample
files and preferably a self-sufficient unit-test which reproduces the problem
more easily.

This will make it much easier for others to reproduce and actually take a look
at the problem.

--
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
|  
Report Content as Inappropriate

[Bug 59158] OpenXML4JRuntimeException: Rule M2.4 exception

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=59158

--- Comment #5 from Javen O'Neal <[hidden email]> ---
> wb.close();
> fo = new FileOutputStream(new File(lokacijaResursa+"\\statistika-"+folder+".xlsx"));
> wb.write(fo);

You cannot use a workbook after it has been closed.
Close your workbook after wb.write and your error should go away.

--
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
|  
Report Content as Inappropriate

[Bug 59158] OpenXML4JRuntimeException: Rule M2.4 exception

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=59158

Javen O'Neal <[hidden email]> changed:

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

--- Comment #6 from Javen O'Neal <[hidden email]> ---
*** Bug 61297 has been marked as a duplicate of this bug. ***

--
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]

Loading...