【问题标题】:AssertionError with BIRT Runtime Engine APIBIRT 运行时引擎 API 的 AssertionError
【发布时间】:2008-09-17 11:20:10
【问题描述】:

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

但我有一个奇怪的例外:

java.lang.AssertionError 在 org.eclipse.birt.core.framework.Platform.startup(Platform.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( );
        }
    }

【问题讨论】:

    标签: java reporting birt


    【解决方案1】:

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

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

    也许你可以通过比较这段代码sn-p和你自己的代码来解决你的问题。顺便说一句,我的 PATH_TO_ENGINE_HOME 是“/WEB-INF/platform”。 [编辑]我使用了 birt-runtime-2_1_1 的 WebViewerExample 中的完整“平台”文件夹。 atm birt-runtime-2_3_0 是实际的。[/edit]

    如果这没有帮助,请提供更多详细信息(例如代码 sn-p)。

    【讨论】:

    • 10x,代码几乎相同......但我仍然有例外......无论如何我不会使用 BIRT 但 JasperReports - 他们工作:)
    【解决方案2】:

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

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

    你应该使用

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

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

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

    我在 Subversion 服务器中设置了几个 Eclipse 项目,这些项目演示了如何使用 Report Engine API (REAPI) 和 Design Engine 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

    【讨论】:

    • 你是对的,这只是一个示例代码,改进的想法很好。斜线无关紧要 - 它适用于所有斜线。感谢您提供资源链接!它终于成功了,但我不会使用它的主要原因是将连接信息作为二进制文件存储在磁盘上。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多