|
|
|||
|
|||
|
用eclipse开发,在SWT画面的按钮事件中,生成html报表,第一次执行,一切正常,不关闭画面,第二次点击按钮的时候。factory.createReportEngine(config);报错。
Exception in thread "main" java.lang.ExceptionInInitializerError at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory.createReportEngine(ReportEngineFactory.java:13) at com.rad.oes.form.CpBillEntry$BtnSend_selected.widgetSelected(CpBillEntry.java:2247) 恳请大师们指点指点。 代码如下, public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { IReportEngine engine = null; IReportEngineFactory factory = null; EngineConfig config = null; try { config = new EngineConfig(); config.setEngineHome("D:/birt-runtime-2_3_1/ReportEngine"); config.setLogConfig("D:/oesproject", Level.FINE); Platform.startup(config); // If using RE API in Eclipse/RCP // application this is not needed. factory = (IReportEngineFactory) Platform .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY); engine = factory.createReportEngine(config); engine.changeLogLevel(Level.WARNING); } catch (Exception ex) { ex.printStackTrace(); } // Run reports, etc. HTMLRenderOption emitterConfig = new HTMLRenderOption(); emitterConfig.setActionHandler(new HTMLActionHandler()); HTMLServerImageHandler imageHandler = new HTMLServerImageHandler(); emitterConfig.setImageHandler(imageHandler); config.getEmitterConfigs().put("html", emitterConfig); IReportRunnable design = null; try { design = engine .openReportDesign("D:/oesproject/reports/new_report.rptdesign"); } catch (EngineException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } // 创建报表任务 IRunAndRenderTask task = engine.createRunAndRenderTask(design); emitterConfig.setBaseURL("http://localhost/"); emitterConfig.setBaseImageURL("http://localhost/myimages"); emitterConfig.setSupportedImageFormats("JPG;PNG;BMP;SVG"); HashMap<String, HTMLRenderOption> contextMap = new HashMap<String, HTMLRenderOption>(); contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, emitterConfig); task.setAppContext(contextMap); // 设置输出本地文件 options.setOutputFileName("D:/oesproject/reports/output.html"); // 设置输出文件格式 options.setOutputFormat("html"); task.setRenderOption(options); // run and render report try { task.run(); } catch (EngineException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } task.close(); engine.destroy(); Platform.shutdown(); } |
![]() |
| 主题工具 | 搜索本主题 |
| 显示模式 | |
|
|