无法生成Birt报告,报告引擎无法初始化空发射器

时间:2015-02-01 16:53:48

标签: java eclipse birt


我正在使用BIRT Runtime Release Build: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);
    }


这是一个例外:
2015年2月1日下午6:32:13 org.eclipse.birt.report.engine.api.impl.EngineTask createContentEmitter
严重:报告引擎无法创建发射器null。 2015年2月1日下午6:32:13 org.eclipse.birt.report.engine.api.impl.EngineTask handleFatalExceptions
严重:运行报告时发生错误。原因: org.eclipse.birt.report.engine.api.EngineException:报告引擎无法初始化null发射器,请确保安装了此发射器所需的库。     at 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)

如何初始化发射器?
发射器需要什么库?
如果有一个完整的例子来生成一个报告,它会很棒。 提前谢谢。

2 个答案:

答案 0 :(得分:1)

我在Birt运行时4_2_2上尝试了相同的代码并且工作正常。请确保添加 birt-runtime-4_2_2 \ ReportEngine \ lib 目录中存在的所有依赖项。请交叉检查下面显示的import语句:

enter image description here

我刚刚在目录中添加了报告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

答案 1 :(得分:0)

我在Birt 4.4.1运行时尝试了以下代码,并且运行成功。

        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);
    }