Bug 51534 - [POI 3.8 beta 3] Exception in thread "main" java.lang.ExceptionInInitializerError
Summary: [POI 3.8 beta 3] Exception in thread "main" java.lang.ExceptionInInitial...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.8-dev
Hardware: PC All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords: APIBug
Depends on:
Blocks:
 
Reported: 2011-07-20 11:40 UTC by tousinnki
Modified: 2011-07-28 13:34 UTC (History)
0 users



Attachments
This is my test data. (29.00 KB, application/vnd.ms-excel)
2011-07-20 11:40 UTC, tousinnki
Details
functionMetadata.txt (7.09 KB, text/plain)
2011-07-28 13:34 UTC, tangchenhui
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tousinnki 2011-07-20 11:40:53 UTC
Created attachment 27302 [details]
This is my test data.

Error occurs when I deal excel 2003 files with POI 3.8 beta 3.
(btw: the file [ExceptionInInitializerError_Testdata.xls] is created by Ms Office 2003 directly.
However, when I tried to open [ExceptionInInitializerError_Testdata.xls] and save it as another file, the bellow exception will not be throwed.
Thanks! ^-^

The exception is as bellow:
============================================================================
Exception in thread "main" java.lang.ExceptionInInitializerError
	at org.apache.poi.ss.formula.ptg.Ptg.createClassifiedPtg(Ptg.java:104)
	at org.apache.poi.ss.formula.ptg.Ptg.createPtg(Ptg.java:85)
	at org.apache.poi.ss.formula.ptg.Ptg.readTokens(Ptg.java:56)
	at org.apache.poi.ss.formula.Formula.getTokens(Formula.java:82)
	at org.apache.poi.hssf.record.FormulaRecord.getParsedExpression(FormulaRecord.java:311)
	at org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate.handleMissingSharedFormulaRecord(FormulaRecordAggregate.java:95)
	at org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate.<init>(FormulaRecordAggregate.java:75)
	at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.construct(ValueRecordsAggregate.java:182)
	at org.apache.poi.hssf.record.aggregates.RowRecordsAggregate.<init>(RowRecordsAggregate.java:109)
	at org.apache.poi.hssf.model.InternalSheet.<init>(InternalSheet.java:207)
	at org.apache.poi.hssf.model.InternalSheet.createSheet(InternalSheet.java:162)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:309)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:260)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:204)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:340)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:321)
	at com.infobases.eltadoc2text.ReadFromFile.readTextFromExcelAndWriteToDB(ReadFromFile.java:128)
	at com.infobases.eltadoc2text.Doc2text.excel2Text(Doc2text.java:336)
	at com.infobases.eltadoc2text.Doc2text.Test_Dox(Doc2text.java:304)
	at com.infobases.eltadoc2text.Doc2text.main(Doc2text.java:63)
Caused by: java.lang.RuntimeException: resource 'functionMetadata.txt' not found
	at org.apache.poi.ss.formula.function.FunctionMetadataReader.createRegistry(FunctionMetadataReader.java:58)
	at org.apache.poi.ss.formula.function.FunctionMetadataRegistry.getInstance(FunctionMetadataRegistry.java:46)
	at org.apache.poi.ss.formula.function.FunctionMetadataRegistry.lookupIndexByName(FunctionMetadataRegistry.java:75)
	at org.apache.poi.ss.formula.ptg.AbstractFunctionPtg.lookupIndex(AbstractFunctionPtg.java:144)
	at org.apache.poi.ss.formula.ptg.FuncVarPtg.create(FuncVarPtg.java:52)
	at org.apache.poi.ss.formula.ptg.FuncVarPtg.<clinit>(FuncVarPtg.java:35)
	... 20 more
Comment 1 Nick Burch 2011-07-20 11:48:53 UTC
The key line is
   java.lang.RuntimeException: resource 'functionMetadata.txt' not found

I'm guessing you've tried to build your own copy of POI? It looks like you've missed out some of the key resources in the process though. You should use the Ant build script to generate your custom jars, as it knows about all the resources you need
Comment 2 tousinnki 2011-07-20 12:21:38 UTC
I'm tried to extract text from Excel 2003. I am not sure why my source should use the resource 'functionMetadata.txt' .
But when I tried to open and save the input file as another file, my source will not use the METADATA FILE 'functionMetadata.txt'.
Why this time I am not missed out some of the key resources in the process?


(In reply to comment #1)
> The key line is
>    java.lang.RuntimeException: resource 'functionMetadata.txt' not found
> I'm guessing you've tried to build your own copy of POI? It looks like you've
> missed out some of the key resources in the process though. You should use the
> Ant build script to generate your custom jars, as it knows about all the
> resources you need
Comment 3 tangchenhui 2011-07-28 13:34:23 UTC
Created attachment 27327 [details]
functionMetadata.txt

As Nick Burch say, I've missed out some of the key resources in the process though. Then, I put the attachment which is named [functionMetadata.txt] in the directory of [org\apache\poi\ss\formula\function], I have fixed this bug. ^-^

Thanks my team member:zhang