I have a Java application to generate Excel sheets. I am doing it based on the BigGridDemo Example of Apache POI to generate Excel(xlsx).
The idea is to
- create a template workbook, create sheets and global objects such as cell styles,number formats etc.
- create an application that streams data in a text file
- Substitute the sheet in the template with the generated data
In Linux, during the 3rd step, the JVM crashes with this info
# A fatal error has been detected by the Java Runtime Environment:
# SIGSEGV (0xb) at pc=0x000000307a772c44, pid=11781, tid=1088649568
#
# JRE version: 6.0_24-b07
# Java VM: Java HotSpot(TM) 64-Bit Server VM (19.1-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libc.so.6+0x72c44] memcpy+0x34
The hs_err_pid file has this -
C [libc.so.6+0x72c44] memcpy+0x34
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j java.util.zip.ZipFile.getNextEntry(JI)J+0
j java.util.zip.ZipFile.access$400(JI)J+2
j java.util.zip.ZipFile$2.nextElement()Ljava/util/zip/ZipEntry;+54
j java.util.zip.ZipFile$2.nextElement()Ljava/lang/Object;+1
Looks like this happens when the template workbook is read as a zip file. This is the code that does this.
ZipFile zip = new ZipFile(zipfile);
ZipOutputStream zos = new ZipOutputStream(out);
Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
while (en.hasMoreElements()) {
ZipEntry ze = en.nextElement();
if(!ze.getName().equals(entry)){
zos.putNextEntry(new ZipEntry(ze.getName()));
InputStream is = zip.getInputStream(ze);
copyStream(is, zos);
is.close();
}
}
How can I avoid this crash?