使用BIRT运行时引擎API的AssertionError

时间:2022-07-02 22:16:40

I'm new to BIRT and I'm trying to make the Report Engine running. I'm using the code snippets provided in http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php

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

But I have a strange exception:

但我有一个奇怪的例外:

java.lang.AssertionError at org.eclipse.birt.core.framework.Platform.startup(Platform.java:86)

org.eclipse.birt.core.framework.Platform.startup(Platform.java:86)中的java.lang.AssertionError

and nothing in the log file.

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

Maybe I missed something in the configuration? Could somebody give me a hint about what I can try to make it running?

也许我错过了配置中的一些东西?有人可以给我一个关于我可以尝试让它运行的提示吗?

Here is the code I'm using:

这是我正在使用的代码:

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 个解决方案

#1


1  

Just a thought, but I wonder if your use of a forward slash when setting the logger is causing a problem? instead of

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

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

you should use

你应该使用

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

or

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

Finally, I realize that this is just some sample code, but you will certainly want to split your platform startup code out from your run and render task. The platform startup is very expensive and should only be done once per session.

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

I have a couple of Eclipse projects that are setup in a Subversion server that demonstrate how to use the Report Engine API (REAPI) and the Design Engine API (DEAPI) that you may find useful as your code gets more complicated.

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

To get the examples you will need either the Subclipse or the Subversive plugins and then you will need to connect to the following repository:

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

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

The projects that you need are:

您需要的项目是:

birt_api_example
birt_runtime_lib
script.lib

You may need to adjust some of the file locations in the BirtUtil class, but I think that most file locations are relative path. There is more information about how to use the examples projects on my blog at http:/birtworld.blogspot.com. In particular this article should help: Testing And Debug of Reports

您可能需要调整BirtUtil类中的某些文件位置,但我认为大多数文件位置都是相对路径。有关如何在我的博客上使用示例项目的更多信息,请访问http:/birtworld.blogspot.com。特别是本文应该有所帮助:报告的测试和调试

#2


2  

I had the same mistake a couple of month ago. I'm not quite sure what actually fixed it but my code looks like the following:

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

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

Perhaps you can solve your problem by comparing this code snippet and your own code. btw my PATH_TO_ENGINE_HOME is "/WEB-INF/platform". [edit]I used the complete "platform"-folder from the WebViewerExample of the birt-runtime-2_1_1. atm birt-runtime-2_3_0 is actual.[/edit]

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

If this doesn't help please give a few more details (for example a code snippet).

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

#1


1  

Just a thought, but I wonder if your use of a forward slash when setting the logger is causing a problem? instead of

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

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

you should use

你应该使用

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

or

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

Finally, I realize that this is just some sample code, but you will certainly want to split your platform startup code out from your run and render task. The platform startup is very expensive and should only be done once per session.

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

I have a couple of Eclipse projects that are setup in a Subversion server that demonstrate how to use the Report Engine API (REAPI) and the Design Engine API (DEAPI) that you may find useful as your code gets more complicated.

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

To get the examples you will need either the Subclipse or the Subversive plugins and then you will need to connect to the following repository:

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

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

The projects that you need are:

您需要的项目是:

birt_api_example
birt_runtime_lib
script.lib

You may need to adjust some of the file locations in the BirtUtil class, but I think that most file locations are relative path. There is more information about how to use the examples projects on my blog at http:/birtworld.blogspot.com. In particular this article should help: Testing And Debug of Reports

您可能需要调整BirtUtil类中的某些文件位置,但我认为大多数文件位置都是相对路径。有关如何在我的博客上使用示例项目的更多信息,请访问http:/birtworld.blogspot.com。特别是本文应该有所帮助:报告的测试和调试

#2


2  

I had the same mistake a couple of month ago. I'm not quite sure what actually fixed it but my code looks like the following:

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

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

Perhaps you can solve your problem by comparing this code snippet and your own code. btw my PATH_TO_ENGINE_HOME is "/WEB-INF/platform". [edit]I used the complete "platform"-folder from the WebViewerExample of the birt-runtime-2_1_1. atm birt-runtime-2_3_0 is actual.[/edit]

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

If this doesn't help please give a few more details (for example a code snippet).

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