代码之家  ›  专栏  ›  技术社区  ›  m_pGladiator

带有BIRT运行时引擎API的断言错误

  •  0
  • m_pGladiator  · 技术社区  · 16 年前

    我是新来的Birt,我正在尝试让报表引擎运行。我正在使用中提供的代码片段 http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php

    但我有一个奇怪的例外:

    java.lang.断言错误 在Org.Eclipse .BiT.Byr.Frask.Stutial.Studio中(Sturial.java:86)

    日志文件中没有任何内容。

    也许我在配置中遗漏了什么?有人能给我一个提示,告诉我怎样才能让它运转起来吗?

    这是我使用的代码:

    public static void executeReport()
        {
    
            IReportEngine engine=null;
            EngineConfig config = null;
    
            try{
                config = new EngineConfig( );           
                config.setBIRTHome("D:\\birt-runtime-2_3_0\\ReportEngine");
                config.setLogConfig("d:/temp", Level.FINEST);
                Platform.startup( config );
                IReportEngineFactory factory = (IReportEngineFactory) Platform
                .createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
                engine = factory.createReportEngine( config );      
    
                IReportRunnable design = null;
                //Open the report design
                design = engine.openReportDesign("D:\\birt-runtime-2_3_0\\ReportEngine\\samples\\hello_world.rptdesign"); 
                IRunAndRenderTask task = engine.createRunAndRenderTask(design);         
    
                HTMLRenderOption options = new HTMLRenderOption();      
                options.setOutputFileName("output/resample/Parmdisp.html");
                options.setOutputFormat("html");
    
                task.setRenderOption(options);
                task.run();
                task.close();
                engine.destroy();
            }catch( Exception ex){
                ex.printStackTrace();
            }       
            finally
            {
                Platform.shutdown( );
            }
        }
    
    2 回复  |  直到 16 年前
        1
  •  1
  •   Scott Rosenbaum    16 年前

    只是一个想法,但我想知道您在设置记录器时使用正斜线是否导致了问题?而不是

    config.setLogConfig("d:/temp", Level.FINEST);
    

    你应该使用

     config.setLogConfig("/temp", Level.FINEST);
    

      config.setLogConfig("d:\\temp", Level.FINEST);
    

    最后,我认识到这只是一些示例代码,但您肯定希望将平台启动代码从运行和呈现任务中分离出来。平台启动非常昂贵,每次会话只需执行一次。

    我有几个Eclipse项目是在Subversion服务器中设置的,它们演示了如何使用报表引擎API(reapi)和设计引擎API(deapi),当代码变得更复杂时,它们可能会很有用。

    要获得示例,您将需要Subclipse或Subversive插件,然后需要连接到以下存储库:

    http://longlake.minnovent.com/repos/birt_example
    

    您需要的项目是:

    birt_api_example
    birt_runtime_lib
    script.lib
    

    您可能需要调整birtutil类中的一些文件位置,但我认为大多数文件位置都是相对路径。有关如何在我的博客http://birtworld.blogspot.com上使用示例项目的更多信息。这篇文章尤其有助于: Testing And Debug of Reports

        2
  •  2
  •   cH1cK3n    16 年前

    几个月前我也犯了同样的错误。我不太确定到底是什么修复了它,但我的代码如下所示:

            IDesignEngine engine = null;
        DesignConfig dConfig = new DesignConfig();
        EngineConfig config = new EngineConfig();
        IDesignEngineFactory factory = null;
        config.setLogConfig(LOG_DIRECTORY, Level.FINE);
        HttpServletRequest servletRequest = (HttpServletRequest) FacesContext.getCurrentInstance()
         .getExternalContext().getRequest();
    
        String u = servletRequest.getSession().getServletContext().getRealPath("/");
        File f = new File(u + PATH_TO_ENGINE_HOME);
    
        log.debug("setting engine home to:"+f.getAbsolutePath());
        config.setEngineHome(f.getAbsolutePath());
    
        Platform.startup(config);
        factory = (IDesignEngineFactory) Platform.createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY);
        engine = factory.createDesignEngine(dConfig);
        SessionHandle session = engine.newSessionHandle(null);
    
        this.design = session.openDesign(u + PATH_TO_MAIN_DESIGN);
    

    也许您可以通过比较这个代码片段和您自己的代码来解决您的问题。btw我的路径是“引擎主页”是“WEB-INF/平台”。[编辑]我使用了Webviewer中完整的“平台”文件夹,例如birt-runtime-2_1_1。atm birt-runtime-2_3_0为实际值。[/edit]

    如果这不起作用,请提供更多详细信息(例如代码片段)。