我正在使用 BIRT 运行时版本:4.4.1
当我尝试生成 Birt 报告时,我遇到了 EngineException。
这是代码:
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);
}
这是异常(exception)情况:
2015 年 2 月 1 日下午 6:32:13 org.eclipse.birt.report.engine.api.impl.EngineTask createContentEmitter
严重:报表引擎无法创建空发射器。
2015 年 2 月 1 日下午 6:32:13 org.eclipse.birt.report.engine.api.impl.EngineTask handlerFatalExceptions
严重:运行报告时发生错误。原因:
org.eclipse.birt.report.engine.api.EngineException:报告引擎无法初始化空发射器,请确保安装了该发射器所需的库。
在 org.eclipse.birt.report.engine.api.impl.EngineTask.createContentEmitter(EngineTask.java:1770)
在 org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:106)
在 org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
在 testBirt.Main.main(Main.java:46)
如何初始化发射器?
发射器需要哪些库?
如果有一个完整的示例来生成报告那就太好了。
提前致谢。
最佳答案
我在 Birt 运行时 4_2_2 上尝试了相同的代码,并且工作正常。请确保添加 birt-runtime-4_2_2\ReportEngine\lib 目录中存在的所有依赖项。请交叉检查如下所示的进口声明:
我刚刚在目录中添加了报告 html 输出,而不是 C:/birt.html
options.setOutputFileName("C:/export_dir/birt.html");
您将在 Birt Report Engine 的 lib 目录中找到所有必需的 jar birt-runtime-4_2_2\ReportEngine\lib
以下是供您引用的依赖项(其中很少有您不需要添加到项目类路径中):
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
关于java - 无法生成 Birt 报告,报告引擎无法初始化空发射器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28265200/