【问题标题】:Can't generate Birt Report, Report engine fails to initialize null emitter无法生成 Birt 报告,报告引擎无法初始化空发射器
【发布时间】:2015-02-01 16:53:48
【问题描述】:


我正在使用 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);
    }


这是一个例外:
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 handleFatalExceptions
严重:运行报告时发生错误。原因: 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)

如何初始化发射器?
发射器需要哪些库?
如果有一个完整的示例来生成报告,那就太好了。 提前致谢。

【问题讨论】:

    标签: java eclipse birt


    【解决方案1】:

    我在 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 目录中找到所有需要的 jars 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
    

    【讨论】:

    • 感谢 Kuldeep,那么,这里需要什么依赖项?
    • 不客气。我修改了答案,请检查并在您的项目类路径中添加所需的依赖项。
    • 谢谢 Kuldeep,我会尽力让你知道结果。
    • 感谢 Kuldeep,我已经尝试导入 jars,它也运行成功了。一些朋友帮我编辑了上面的代码,让它使用 Birt 4.4.1 运行时库。
    【解决方案2】:

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

    【讨论】:

    • 感谢@Kuldeep 的努力。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多