Bug 43251 - Unable to construct record instance, the following exception occured
Summary: Unable to construct record instance, the following exception occured
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-FINAL
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-30 06:57 UTC by Sandeep Giri
Modified: 2008-03-19 04:59 UTC (History)
1 user (show)



Attachments
An excel file that fails in the constructor with RecordFormatException: "Unable to construct record instance" (162.50 KB, application/vnd.ms-excel)
2008-03-18 13:07 UTC, Lucas Shaw
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sandeep Giri 2007-08-30 06:57:50 UTC
Hi,
I am getting the following error.
Please let me know how can I send the sample attachment for which this problem
is occurring. 

Regards,
Sandeep Giri
------------------------------
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:237)
	at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:160)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:183)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:152)
	at transbit.tbits.Helper.Xls2csv.getText(Xls2csv.java:42)
	at transbit.tbits.Helper.Xls2csv.getText(Xls2csv.java:32)
	at transbit.tbits.common.Readerizer.readerizeExcelFiles(Readerizer.java:322)
	at transbit.tbits.common.Readerizer.readerize(Readerizer.java:209)
	at transbit.tbits.common.Readerizer.main(Readerizer.java:136)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 33
	at org.apache.poi.util.LittleEndian.getNumber(LittleEndian.java:491)
	at org.apache.poi.util.LittleEndian.getShort(LittleEndian.java:52)
	at org.apache.poi.hssf.record.ObjRecord.fillFields(ObjRecord.java:98)
	at org.apache.poi.hssf.record.Record.fillFields(Record.java:90)
	at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
	at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
	... 13 more
org.apache.poi.hssf.record.RecordFormatException: Unable to construct record
instance, the following exception occured: null
	at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:250)
	at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:160)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:183)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:152)
Comment 1 Nick Burch 2007-09-03 09:27:05 UTC
You should attach the problem file to this bugzilla entry
Comment 2 Lucas Shaw 2008-03-18 13:07:30 UTC
Created attachment 21679 [details]
An excel file that fails in the constructor with RecordFormatException: "Unable to construct record instance"

Assuming xlsFile is a File object that points to the Problem.xls file the following code fails:

inputStream_ = new FileInputStream( xlsFile );
POIFSFileSystem fs = new POIFSFileSystem( inputStream_ );
workbook_ = new HSSFWorkbook( fs ); //FAILS HERE

Here's a stack trace:
org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance
	at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:199)
	at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:117)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:207)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:148)
	at com.snowfly.spincast.XlsSheetList.open(XlsSheetList.java:50)
	at com.snowfly.spincast.XlsSheetList.<init>(XlsSheetList.java:36)
	at com.snowfly.spincast.client.XLSFileImporter.processFile(XLSFileImporter.java:63)
	at com.snowfly.spincast.client.XLSFileImporter.doImport(XLSFileImporter.java:45)
	at com.snowfly.spincast.Task.process(Task.java:74)
	at com.snowfly.spincast.TaskManager.process(TaskManager.java:33)
	at com.snowfly.spincast.Spincast.main(Spincast.java:34)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:187)
	... 10 more
Caused by: java.lang.IllegalArgumentException: Illegal length
	at org.apache.poi.hssf.record.RecordInputStream.readCompressedUnicode(RecordInputStream.java:270)
	at org.apache.poi.hssf.record.FileSharingRecord.fillFields(FileSharingRecord.java:62)
	at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
	at org.apache.poi.hssf.record.FileSharingRecord.<init>(FileSharingRecord.java:48)
	... 15 more
Comment 3 Nick Burch 2008-03-19 04:59:54 UTC
I've just tried the attached spreadsheet, and it opens just fine with svn
trunk

I've added a new test to the test suite, so we can ensure this doesn't get
broken again in future