I am trying to edit excel file using Apache POI
and OPCPackage
and it is not working out for me for some weird reasons. Here is the code snippet:
File file = new File(basePath, fileName);
int currentColNum=0, currentRowNum=0;
OPCPackage pkg = null;
Workbook wb = null;
if(file.exists())
pkg = OPCPackage.open(file);
wb = new XSSFWorkbook(pkg);
else
wb = new XSSFWorkbook();
Sheet sheet = wb.getSheet(sheetName);
if(sheet==null)
sheet = wb.createSheet(sheetName);
else
currentRowNum = lastWrittenRowCol.get(sheetName).getLeft();
for(Entry<?,?> entry : map.entrySet()) {
//some code. This code uses functions like sheet.createRow() etc.
}
FileOutputStream out = new FileOutputStream(file);
System.out.println("before write.out"); //Printed/
wb.write(out);
System.out.println("last statement"); //Not printed.
out.close();
if(pkg!=null)
pkg.close();
I get the following error:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGBUS (0x7) at pc=0x00002b517248dae2, pid=14557, tid=47628802967872
#
# JRE version: 7.0_25-b15
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.25-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libzip.so+0x4ae2] newEntry+0x62
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
And this is the memory information from the log:
/proc/meminfo:
MemTotal: 5855708 kB
MemFree: 1413996 kB
Buffers: 815896 kB
Cached: 1939120 kB
SwapCached: 0 kB
Active: 2339452 kB
Inactive: 1512396 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 5855708 kB
LowFree: 1413872 kB
SwapTotal: 5140792 kB
SwapFree: 5140792 kB
Dirty: 5556 kB
Writeback: 0 kB
AnonPages: 1096860 kB
Mapped: 112944 kB
Slab: 520072 kB
PageTables: 39008 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 8068644 kB
Committed_AS: 2106544 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 51844 kB
VmallocChunk: 34359686179 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
Hugepagesize: 2048 kB
I am using Eclipse. Program was run with arguments -Xms512m -Xmx2048m
. There is some problem with wb.write(out)
because statement just before that line is printed but the next is not. (I know I should use debugger but I do not know how to plug it in in eclipse from our build system). Any help appreciated!