从 BIRT 2.5.2 升级到 3.7.1
我们之前使用下面的代码来设置 BIRT 引擎以在我们的 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;
}
We previously used the code below to set up BIRT Engine to use within our servlet, the migration guide says you just need to add the BIRT jars to the classpath, the BIRT jars were added to WEB-INF\lib.
When we run the app now, IReportEngineFactory
returns null. Any help is appreciated.
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加以下行解决了我的自定义 BirtEngine.java 配置中的问题:
Adding the following line solved the problem in my custom BirtEngine.java configuration:
在网上的许多帖子中,我读到您不能再设置 BIRT 主目录和平台上下文。所以你的代码应该变成这样:
On many posts in the net I read you must not set BIRT home and platform context anymore. So your code should become something like this: