Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource leak: workbook is never closed warning when using Apache.POI XSSFWorkbook

So, I using Apache POI in order to parse an Excel file to my Database. For this I am initializing an XSSFWorkbook as follows:

XSSFWorkbook workbook = new XSSFWorkbook(fIP);

Then I proceed with my method. workbook.close() is not available as a method to close the workbook afterwards. Any ideas of how can I let garbage collection take the workbook after the task is finished?

like image 212
rpd Avatar asked Aug 05 '15 11:08

rpd


1 Answers

I had this issue, and it was making little sense. In the end I tracked the issue down to my IDE (netbeans) was picking up an earlier version of the POI libraries (v3.8) which didn't have the "close" method. So check your class path and look for duplicate imports of different versions of the POI libraries.

like image 95
IanB Avatar answered Sep 19 '22 00:09

IanB