Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1 [message #489650] |
Mon, 05 October 2009 09:36  |
Eclipse User |
|
|
|
Hi,
i have an Eclipse RCP with a helper-class for printing / exporting to PDF, where I load the design, set some Parameters and save the PDF-File. After upgrading to 2.5.1, I'm getting a NullPointerException in ReportExecutor when running the task. So
private ByteArrayOutputStream generateOutput(int report)
throws EngineException {
...
task.run();
...
}
results in NPE
05.10.2009 14:55:42 org.eclipse.birt.report.engine.api.impl.RunAndRenderTask doRun
SCHWERWIEGEND: An error happened while running the report. Cause:
java.lang.NullPointerException
at org.eclipse.birt.report.engine.executor.ReportExecutor.execute(ReportExecutor.java:123)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportExecutor.execute(WrappedReportExecutor.java:60)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplciateReportExecutor.execute(SuppressDuplciateReportExecutor.java:42)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportExecutor.execute(WrappedReportExecutor.java:60)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:168)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:75)
at de.itrn.svp.printing.PrintingEngine.generateOutput(PrintingEngine.java:298)
at de.itrn.svp.printing.PrintingEngine.<init>(PrintingEngine.java:114)
at de.itrn.sv.finance.views.InvoiceView$4.widgetSelected(InvoiceView.java:165)
...
any hints, what changed in 2.5.1?
thanks
Ralf
public class PrintingEngine {
private IReportRunnable design;
private int dialogResult;
private ReportEngine engine;
private EngineConfig engineConfig;
private final Object model;
private ByteArrayOutputStream outputStream;
private final Integer outputType;
private IRunAndRenderTask task;
ElementFactory designFactory = null;
ReportDesignHandle designHandle = null;
StructureFactory structFactory = null;
public PrintingEngine(Object model, Integer outputType, Boolean print,
int report) {
this.model = model;
this.outputType = outputType;
try {
initEngine(report);
loadReportDesign(report);
task = engine.createRunAndRenderTask(design);
setConnectionParameters();
generateOutput(report);
} catch (EngineException e) {
e.printStackTrace();
}
if (print) {
print(outputStream);
}
closeEngine();
}
private ByteArrayOutputStream generateOutput(int report)
throws EngineException {
IRenderOption options = new RenderOption();
options.setOutputStream(outputStream);
switch (outputType) {
case PT_PDF:
RenderContext pdfCtx = new RenderContext(new ExecutionContext());
HashMap<String, RenderContext> pdfContextMap = new HashMap<String, RenderContext>();
pdfContextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT,
pdfCtx);
task.setAppContext(pdfContextMap);
options.setOutputFormat("pdf");
break;
...
default:
break;
}
// Set PrintDate
task.setParameterValue("printDate", DisplayFormat.shortDate(new Date()));
// Fill by ReportType
switch (report) {
case RPT_INVOICE:
task.setParameterValue("id_invoice",
((Invoice) model).getIdInvoice());
task.setParameterValue("ust", 19);
break;
...
case RPT_REMINDER1:
Invoice invoice = (Invoice) model;
task.setParameterValue("id_invoice", invoice.getIdInvoice());
task.setParameterValue("dialogResult", dialogResult);
break;
default:
break;
}
outputStream = new ByteArrayOutputStream();
options.setOutputStream(outputStream);
task.setRenderOption(options);
task.run();
return outputStream;
}
private void initEngine(int report) throws EngineException {
// create instance of EngineConfig
engineConfig = new EngineConfig();
engineConfig.setLogConfig(LOGDIR, Level.ALL);
engine = new ReportEngine(engineConfig);
engine.changeLogLevel(Level.FINE);
}
private void setConnectionParameters() {
task.setParameterValue("jdbc_driver_class", "org.postgresql.Driver");
task.setParameterValue("db_user",
de.itrn.sv.database.Activator.getDefault()
.getPreferenceStore()
.getString(DatabasePreferenceConstants.P_DBUSER));
task.setParameterValue("jdbc_driver_url", "jdbc:postgresql://"
+ de.itrn.sv.database.Activator.getDefault()
.getPreferenceStore()
.getString(DatabasePreferenceConstants.P_DBHOST) + "/"
+ de.itrn.sv.database.Activator.getDefault()
.getPreferenceStore()
.getString(DatabasePreferenceConstants.P_DBNAME));
task.setParameterValue("db_password",
de.itrn.sv.database.Activator.getDefault()
.getPreferenceStore()
.getString(DatabasePreferenceConstants.P_DBPASSWD));
}
private void closeEngine() {
task.close();
engine.destroy();
}
private void loadReportDesign(int report) throws EngineException {
String reportFile = Activator.getDefault()
.getPreferenceStore()
.getString(PrintingPreferenceConstants.TPL_PATH);
switch (report) {
case RPT_INVOICE:
reportFile += "invoice.rptdesign";
design = engine.openReportDesign(reportFile);
break;
...
case RPT_REMINDER1:
reportFile += "reminder1.rptdesign";
design = engine.openReportDesign(reportFile);
break;
default:
break;
}
}
public String save(ByteArrayOutputStream bos, String fileName) {
try {
// Redirect to File
String path = Activator.getDefault()
.getPreferenceStore()
.getString(PrintingPreferenceConstants.PDF_OUTPUT);
if (fileName == null) {
fileName = path + "/tmpPrint.pdf";
} else {
fileName = path + fileName + ".pdf";
}
OutputStream out = new FileOutputStream(fileName);
bos.writeTo(out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
return fileName;
}
}
|
|
|
|
|
|
|
|
|
|
Re: Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1 [message #490958 is a reply to message #490638] |
Mon, 12 October 2009 11:13   |
Eclipse User |
|
|
|
Gerald,
Can you add this information to a bugzilla entry?
Jason
Gerald Ploner wrote:
> Hello Jason,
>
> I continued the problem analysis and I got a more precise result:
>
> 1) If I explicitly download BIRT 2.5.1 with the eclipse update manager then
> the report creation works fine.
> 2) If I download the plugins of our software with the eclipse update manager
> then the report creation fails with a NullPointerException:
>
> java.lang.NullPointerException
> at
> org.eclipse.birt.report.engine.executor.ReportExecutor.execu te(ReportExecutor.java:123)
> at
> org.eclipse.birt.report.engine.internal.executor.wrap.Wrappe dReportExecutor.execute(WrappedReportExecutor.java:60)
> at
> org.eclipse.birt.report.engine.internal.executor.dup.Suppres sDuplciateReportExecutor.execute(SuppressDuplciateReportExec utor.java:42)
> at
> org.eclipse.birt.report.engine.internal.executor.wrap.Wrappe dReportExecutor.execute(WrappedReportExecutor.java:60)
> at
> org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doR un(RunAndRenderTask.java:168)
> at
> org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run (RunAndRenderTask.java:75)
>
> (The DataEngine seems to be null. "ExecutionContext.openDataEngine()"
> catches an exception)
>
> 3) The only dependency of our report creation plugin to a BIRT plugin is:
> "org.eclipse.birt.report.engine". In the past this was enough to get the
> necessary BIRT plugins to create the report successfully (with BIRT 2.1.x,
> 2.2.x, 2.3.x).
> 4) Now I detected that, if I add the plugin
> "org.eclipse.birt.report.engine.script.javascript" (seems to be new in BIRT
> 2.5.1) manually to the plugins downloaded via eclipse update manager, the
> report generation works fine.
>
> Is it really necessary to add a new explicit plugin dependency to this new
> plugin? We would have a problem in this case because our report generator
> plugin have to work with eclipse 3.2 (BIRT 2.1.x), eclipse 3.2 (BIRT 2.2.x)
> and eclipse 3.4 (BIRT 2.3.x), too.
> And then I assume that we get a problem because in elder BIRT versions this
> plugin doesn't exist...
>
> Or is it a missing dependency bug within BIRT 2.5.1?
>
> Best regards,
> Gerald.
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.05691 seconds