2012-01-06 127 views
0

我们以前使用下面的代码来设置BIRT引擎以在我们的servlet中使用,迁移指南中说您只需将BIRT jar添加到classpath中,BIRT jar就是添加到WEB-INF \ lib。从BIRT 2.5.2升级到3.7.1

当我们现在运行应用程序时,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; 
} 
+0

我面对完全相同的问题。 从BIRT 2.5.2升级到BIRT 3.7.1时。你解决了这个问题吗? Thanx提前,Nele – Nele 2012-01-31 10:41:44

回答

0

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

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

感谢您的更新,我们还没有解决问题。我会尝试你的解决方案。 – kallen 2012-02-01 15:03:44

0

论我看了你不能设置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; 
}