Search code examples
javaeclipselog4jlaunch4jxlsm

launch4j: java.lang.OutOfMemoryError: GC overhead limit exceeded


I added the poi-4.1.1.jar and all the libraries coming with to my java project for reading .xlsm files. After adapting the code, I could compile and run it in Eclipse without any problems.

I export > Runnable JAR file > Extract required libraries into generated JAR; getting a jar-File. Then made an exe with launch4j and test the wrapper and it doesnt work when it comes to read the .xlsm-file (see log)

Starting the jar-file with the command line java -jar foo.jar worked perfectly

I dont use maven or ant.

I've searched a long time and there are several question to this error, but nothing helped..The amount of data for the .xls and the .xlsm file is the same. Generating exe's with an older poi-library worked several times

Executing: D:\foo.exe
log4j:WARN No appenders could be found for logger (bar).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "Thread-5" java.lang.OutOfMemoryError: GC overhead limit exceeded
    at org.apache.xmlbeans.impl.store.Cur$CurLoadContext.attr(Cur.java:3044)
    at org.apache.xmlbeans.impl.store.Cur$CurLoadContext.attr(Cur.java:3065)
    at org.apache.xmlbeans.impl.store.Locale$SaxHandler.startElement(Locale.java:3216)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3422)
    at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1272)
    at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1259)
    at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.WorksheetDocument$Factory.parse(Unknown Source)
    at org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:226)
    at org.apache.poi.xssf.usermodel.XSSFSheet.onDocumentRead(XSSFSheet.java:218)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.parseSheet(XSSFWorkbook.java:448)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead(XSSFWorkbook.java:413)
    at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:184)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:282)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:303)
    at doImport(ImporterMain.java:249)
    at ImporterMain.run(ImporterMain.java:211)
    at java.lang.Thread.run(Unknown Source)
  • Do I have to go through the code and delete comments or unused code?
  • where can I see what the GC limit is?
  • where can I adapt it?
  • what's about the log4j warnings? how can I append the logger?

Thanks for advice to a rookie-java-programmer

Cheers,


Solution

  • I could finally solve it.

    I'm using a config-File for my launch4j-application for having the same configs everytime I generate an exe. I missed, that in the tab "JRE" of launch4j, the garbbage collector was define to -Xmx300m.

    Increasing the garbbage collector to -Xmx1g solved the problem and my exe is now working perfectly.