[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.birt] Re: setting PARENT_CLASSLOADER in birt 2.3
|
- From: kms@xxxxxxxxx (Kanu)
- Date: Wed, 2 Jul 2008 05:52:54 +0000 (UTC)
- Newsgroups: eclipse.birt
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
OK? I have tried this.
Here is my code:
protected void generateReport(OutputStream fos, String format) throws
ReportException {
IReportEngine engine = createReportEngine();
IRenderOption options = createRenderOption(fos, format);
IReportRunnable design = engine.openReportDesign(templateInputStream);
createRunAndRenderTask(design, options, engine);
destroyReportEngine(engine);
}
protected final IReportEngine createReportEngine() {
EngineConfig config = new EngineConfig();
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
HashMap mh = (HashMap)config.getAppContext();
mh.put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY,
StaticObjectHolder.class.getClassLoader());
config.setAppContext(mh);
try {
Platform.startup( config );
} catch (BirtException e) {
e.printStackTrace();
}
return factory.createReportEngine(config);
}
protected final IRenderOption createRenderOption(OutputStream fos, String
format) throws ReportException {
IRenderOption options = null;
do {
if (format.equalsIgnoreCase(IReportViewer.HTML)) {
options = new HTMLRenderOption();
break;
}
if (format.equalsIgnoreCase(IReportViewer.PDF)) {
options = new PDFRenderOption();
break;
}
if (format.equalsIgnoreCase("xls")) {
options = new RenderOption();
break;
}
throw new ReportException("Bad Format");
} while (false);
options.setOutputStream(fos);
options.setOutputFormat(format);
return options;
}
protected final void createRunAndRenderTask(IReportRunnable design,
IRenderOption options, IReportEngine engine)
throws ReportException {
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
Map params = new HashMap();
addParams(params);
task.setParameterValues(params);
task.setRenderOption(options);
try {
task.run();
} catch (EngineException e) {
throw new ReportException(e.getMessage(), e);
}
task.close();
}
protected final void destroyReportEngine(IReportEngine engine) {
engine.destroy();
}
But I still get the error:
02.07.2008 11:49:34 org.eclipse.birt.report.engine.api.impl.EngineTask
isDeprecatedEntry
WARNING: PARENT_CLASSLOADER could not be set in appContext of IEngineTask,
please set it in appContext of IReportEngine
02.07.2008 11:49:35
org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor handleJS
WARNING: A BIRT exception occurred: Error evaluating Javascript
expression. Script engine error: ReferenceError: "StaticObjectHolder" is
not defined. (<inline>#5)
Script source: <inline>, line: 1, text:
__bm_OPEN().