【问题标题】:Upgrading from BIRT 2.5.2 to 3.7.1从 BIRT 2.5.2 升级到 3.7.1
【发布时间】:2012-01-06 16:57:55
【问题描述】:

我们之前使用下面的代码来设置 BIRT Engine 以在我们的 servlet 中使用,迁移指南说您只需将 BIRT jar 添加到类路径,BIRT jar 已添加到 WEB-INF\lib。

当我们现在运行应用程序时,IReportEngineFactory 返回 null。任何帮助表示赞赏。

public static synchronized IReportEngine getBirtEngine(ServletContext sc) throws Exception {

    EngineConfig config  = new EngineConfig();
    config.setBIRTHome("");


    config.setLogConfig("C:/Temp", Level.FINEST);
    config.setLogFile("birtLog.log");
    realPath = sc.getRealPath("/reports");
    log.info("Server Info:  " + sc.getServerInfo());
    log.info(" Servlet Context Name:  " + sc.getServletContextName());
    log.info("Real Path:  " + realPath);
    log.info("#####Creating new Birt Engine#####");
    //log.info("Birt Home is: " + config.getBIRTHome());
    IPlatformContext context = new PlatformServletContext(sc);
    config.setPlatformContext(context);
    try {
        Platform.startup(config);
        //log.info("Birt Home is: " + config.getPlatformContext().toString());
        IReportEngineFactory factory =  (IReportEngineFactory) Platform.createFactoryObject
                (IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
        birtEngine = factory.createReportEngine(config);
    }
    catch (Exception e ) {
        throw e;
    }

    return birtEngine;
}

【问题讨论】:

  • 我面临着完全相同的问题。从 BIRT 2.5.2 升级到 BIRT 3.7.1 时。你解决了这个问题吗?提前感谢,内尔

标签: war birt


【解决方案1】:

添加以下行解决了我的自定义 BirtEngine.java 配置中的问题:

IPlatformContext context = new PlatformServletContext(sc);
config.getAppContext().put(EngineConstants.WEBAPP_CLASSPATH_KEY, "");

【讨论】:

  • 感谢您的更新,我们还没有解决问题。我会尝试您的解决方案。
【解决方案2】:

在我阅读的网络上的许多帖子中,您不能再设置 BIRT 主页和平台上下文。所以你的代码应该是这样的:

public static synchronized IReportEngine getBirtEngine() throws Exception {

    EngineConfig config  = new EngineConfig();
    config.setLogConfig("C:/Temp", Level.FINEST);
    config.setLogFile("birtLog.log");

    try {
        Platform.startup(config);
        IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject
                (IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
        birtEngine = factory.createReportEngine(config);
    }
    catch (Exception e ) {
        throw e;
    }

    return birtEngine;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-28
    • 2023-03-26
    • 2012-05-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多