Reputation: 454
I'm using BIRT Runtime Release Build: 4.4.1
I'm facing EngineException when I try to generate a Birt report.
Here is the code:
try {
final EngineConfig config = new EngineConfig();
// delete the following line if using BIRT 3.7 (or later) POJO
// runtime
// As of 3.7.2, BIRT now provides an OSGi and a POJO Runtime.
config.setEngineHome("C:/Mine/ReportEngine/lib");
// config.setLogConfig(c:/temp, Level.FINE);
Platform.startup(config);
// If using RE API in Eclipse/RCP application this is not needed.
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
IReportEngine engine = factory.createReportEngine(config);
engine.changeLogLevel(Level.WARNING);
IReportRunnable report = engine
.openReportDesign("C:/Mine/BirtTraining/demo/demo.rptdesign");
IRunAndRenderTask task = null;
task = engine.createRunAndRenderTask(report);
HTMLRenderOption options = null;
options = new HTMLRenderOption();
options.setOutputFileName("C:/birt.html");
task.setRenderOption(options);
task.run();
System.out.println("All went well. Closing program!");
engine.destroy();
System.exit(0);
} catch (Exception ex) {
ex.printStackTrace();
System.err.println("An error occured while running the report!");
System.exit(-1);
}
Here is the exception:
Feb 1, 2015 6:32:13 PM org.eclipse.birt.report.engine.api.impl.EngineTask createContentEmitter
SEVERE: Report engine can not create emitter null.
Feb 1, 2015 6:32:13 PM org.eclipse.birt.report.engine.api.impl.EngineTask handleFatalExceptions
SEVERE: An error happened while running the report. Cause:
org.eclipse.birt.report.engine.api.EngineException: Report engine fails to initialize null emitter, please make sure required libraries for this emitter are installed.
at org.eclipse.birt.report.engine.api.impl.EngineTask.createContentEmitter(EngineTask.java:1770)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:106)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
at testBirt.Main.main(Main.java:46)
How can I initialize an emitter?
What are required libraries for the emitter?
If there is a complete example to generate a report it will be great.
Thanks in advance.
Upvotes: 0
Views: 3722
Reputation: 454
I tried the following code with Birt 4.4.1 runtime and it run successfully.
try {
System.setProperty("org.eclipse.datatools_workspacepath",
"C:/Mine/abdo");
intBirtEngine();
// If using RE API in Eclipse/RCP application this is not needed.
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
IReportRunnable report = engine.openReportDesign(Main.class
.getResourceAsStream("/pojo.rptdesign"));
IRunAndRenderTask task = engine.createRunAndRenderTask(report);
Map<String, List<StockData>> birtParams = new HashMap<String, List<StockData>>();
birtParams.put("list",
new StockDaoMock().getStockValues("Java"));
System.out.println("my list\n"+new StockDaoMock().getStockValues("Java").size());
task.setParameterValues(birtParams);
IRenderOption options = new EXCELRenderOption();
options.setOutputFormat("xls");
options.setOutputFileName("C:/demo/birt9.xls");
System.out.println(new Date());
task.setRenderOption(options);
task.run();
task.close();
destroyPlatform();
System.out.println("All went well. Closing program!");
System.exit(0);
} catch (Exception ex) {
ex.printStackTrace();
System.err.println("An error occured while running the report!");
System.exit(-1);
}
Upvotes: 0
Reputation: 570
I tried the same code with the Birt runtime 4_2_2 and it's working fine.Make sure you add all the dependencies present in the birt-runtime-4_2_2\ReportEngine\lib directory. Please cross check the import statement shown below :
I just added the report html output in the directory instead of C:/birt.html
options.setOutputFileName("C:/export_dir/birt.html");
You will find all the required jars in the Birt Report Engine's lib directory birt-runtime-4_2_2\ReportEngine\lib
Below are the dependencies for your reference(Few of them you won't need to add in your project classpath):
org.eclipse.emf_2.6.0.v20130125-0826.jar
org.eclipse.equinox.app_1.3.100.v20120522-1841.jar
org.eclipse.equinox.common_3.6.100.v20120522-1841.jar
org.eclipse.equinox.preferences_3.5.1.v20121031-182809.jar
org.eclipse.equinox.registry_3.5.200.v20120522-1841.jar
org.eclipse.osgi.services_3.3.100.v20120522-1822.jar
org.eclipse.osgi_3.8.2.v20130124-134944.jar
org.w3c.css.sac_1.3.0.v200805290154.jar
org.w3c.dom.smil_1.0.0.v200806040011.jar
org.w3c.dom.svg_1.1.0.v201011041433.jar
Tidy.jar
com.ibm.icu_4.4.2.v20110823.jar
js.jar
com.lowagie.text_2.1.7.v201004222200.jar
commons-cli-1.0.jar
derby.jar
flute.jar
javax.wsdl_1.5.1.v201012040544.jar
javax.xml.stream_1.0.1.v201004272200.jar
org.eclipse.datatools.connectivity.oda_3.3.4.v201212070447.jar
org.apache.batik.parser_1.6.0.v201011041432.jar
org.apache.batik.util_1.6.0.v201011041432.jar
org.apache.batik.xml_1.6.0.v201011041432.jar
org.apache.batik.bridge_1.6.0.v201011041432.jar
org.apache.batik.css_1.6.0.v201011041432.jar
org.apache.batik.dom.svg_1.6.0.v201011041432.jar
org.apache.batik.dom_1.6.0.v201011041432.jar
org.apache.batik.ext.awt_1.6.0.v201011041432.jar
org.apache.batik.pdf_1.6.0.v201105071520.jar
org.apache.batik.svggen_1.6.0.v201011041432.jar
org.apache.batik.transcoder_1.6.0.v201011041432.jar
org.apache.batik.util.gui_1.6.0.v201011041432.jar
Upvotes: 1