Bug 465535 - Using embedded POI in BIRT 4.4.2 throws exception "WorkbookFactory.create is not a function, it is object"
Summary: Using embedded POI in BIRT 4.4.2 throws exception "WorkbookFactory.create is ...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 4.4.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Birt-Build CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-27 03:46 EDT by Silvester Rößner CLA
Modified: 2015-04-27 05:45 EDT (History)
0 users

See Also:


Attachments
poi.rptdesign reproduces the exception (6.58 KB, application/x-zip-compressed)
2015-04-27 03:48 EDT, Silvester Rößner CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Silvester Rößner CLA 2015-04-27 03:46:18 EDT
can somebody please give me a hint what I am doing wrong here?

When I try to use the embedded POI in BIRT 4.4.2, I get the below exception. Everything works fine with BIRT 4.2.2.

I have tried to fix this myself, but with no luck. Perhaps my problem is the same as the one described in Bug 398774 - POI version conflict caused by BIRT Runtime 4.2.0. But I can't figure this out.

To reproduce the error simply generate a report from poi.rptdesign contained in poi.zip. It contains mainly this code, which tries to open an excel file

	// Just load the excel file
	// and show that org.apache.poi.ss.usermodel.ShapeTypes is well defined
	var fis = new Packages.java.io.FileInputStream(wd + "poi.xls");
	dbg.println("ACTION_BUTTON_DOCUMENT " +
	     typeof Packages.org.apache.poi.ss.usermodel.ShapeTypes.ACTION_BUTTON_DOCUMENT + " " +
	     Packages.org.apache.poi.ss.usermodel.ShapeTypes.ACTION_BUTTON_DOCUMENT);
	dbg.println("fis " + typeof fis + " " + fis);
	
	// The following line works fine with BIRT 4.2.2 but fails with BIRT 4.4.2
	var wb = new Packages.org.apache.poi.ss.usermodel.WorkbookFactory.create(fis);



Exception details (see also poi.zip/poi.stderr.log)

TypeError: [JavaPackage org.apache.poi.ss.usermodel.WorkbookFactory.create] is not a function, it is object. (/report/method[@name="beforeFactory"]#14)
	at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:249)
	at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleBeforeFactory(ReportScriptExecutor.java:122)
	at org.eclipse.birt.report.engine.api.impl.EngineTask.startFactory(EngineTask.java:2030)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:101)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
	at org.eclipse.birt.report.engine.api.ReportRunner.runAndRenderReport(ReportRunner.java:245)
	at org.eclipse.birt.report.engine.api.ReportRunner.execute(ReportRunner.java:168)
	at org.eclipse.birt.report.engine.api.ReportRunner.main(ReportRunner.java:127)
Comment 1 Silvester Rößner CLA 2015-04-27 03:48:01 EDT
Created attachment 252778 [details]
poi.rptdesign reproduces the exception
Comment 2 Silvester Rößner CLA 2015-04-27 05:45:10 EDT
Eventually I found a work around that works for me:

1. Copy every class from
      org.apache.poi_3.9.0.v201303080712.jar
   to
      org.eclipse.birt.runtime_4.4.2.v20150217-1805.jar

2. Rename 
      org.eclipse.birt.runtime_4.4.2.v20150217-1805.jar
   into 
      org.eclipse.birt.runtime_4.4.2.v20150217-1805-poi.jar

3. Delete
      org.apache.poi_3.9.0.v201303080712.jar

This is all you need to be able to run a report with genReport.bat. In order to run a report in Eclipse, you have to

4. Add
      org.eclipse.birt.runtime_4.4.2.v20150217-1805-poi.jar
   to
      Eclipse-Project->Properites->Report Design->Classpath->Add External JARs...
   or as a resource to the report itself
      Report->Property Editor->Resources->Jar Files->Add File...
      
I know this is very, very ugly.