Birt类EngineException的NoClassDefFoundError

时间:2013-07-26 07:46:46

标签: java eclipse installation birt

是否有人成功将Birt库添加到项目的构建路径

我在Eclipse中使用帮助安装Birt - >安装新软件并从官方网站复制粘贴Birt 4.2.2的链接。 Birt从互联网上下载,出现了一个新的视角,即报告设计。除了它没有图书馆,没有什么。所以我设计了我的报告并开始编写Java代码,以便对我的报告进行PDF导出,就像我在互联网上找到的那样。我写了以下内容:

// Export Birt report
        String format = HTMLRenderOption.OUTPUT_FORMAT_PDF;
        EngineConfig config = new EngineConfig( );
        config.setEngineHome( "C:\\Tools\\Eclipse\\plugins\\org.eclipse.birt.report.viewer_4.2.2.v201302041142\\birt" );
        HTMLEmitterConfig hc = new HTMLEmitterConfig( );
        HTMLCompleteImageHandler imageHandler = new HTMLCompleteImageHandler( );
        hc.setImageHandler( imageHandler );
        config.setEmitterConfiguration( HTMLRenderOption.OUTPUT_FORMAT_HTML, hc );
        ReportEngine engine = new ReportEngine( config );
        IReportRunnable report = null;
        String reportFilepath = "C:/Workspace/reports/new_report.rptdesign";
        try {
            report = engine.openReportDesign( reportFilepath );
        }
        catch ( EngineException e ) {
            System.err.println( "Report " + reportFilepath + " not found!\n" );
            engine.destroy( );
            return;
        }
        IRunAndRenderTask task = engine.createRunAndRenderTask( report );
        HTMLRenderOption options = new HTMLRenderOption( );
        options.setOutputFormat( format );
        options.setOutputFileName( "C:/Workspace/reports/output.pdf" );
        task.setRenderOption( options );
        task.setParameterValues( parametersMap );
        try {
            task.run( );
        }
        catch ( EngineException e1 ) {
            System.err.println( "Report " + reportFilepath + " run failed.\n" );
            System.err.println( e1.toString( ) );
        }
        engine.destroy( );
        return;

当然在我的构建路径中没有设置Birt库,因此所有Birt对象都是红色的。我手动添加了Eclipse插件文件夹中存在的所有Birt jar,所有的红色都消失了。似乎一切都很顺利。当我运行它时,我得到:

java.lang.NoClassDefFoundError: org/eclipse/birt/report/engine/api/EngineException

而我的构建路径中存在org.eclipse.birt.report.engine.api包 并且包中存在EngineException.class。我觉得有一些我遗漏的jar文件。 我在Birt主页上搜索了一个解决方案但没有找到任何结果。大多数教程都有关于如何构建报告的说明。但没有关于如何使用Java启动和运行库。

是否有标准或自动或官方的方式将Birt库添加到Eclipse?它是由Eclipse制作的。它不应该那么困难。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:3)

您是否已阅读本页 - > http://wiki.eclipse.org/Servlet_Example_(BIRT)_2.1 也许你可以在那里找到一些提示。

相关问题