2012-01-06 54 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; 
}