Skip to main content



      Home
Home » Archived » BIRT » Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1
Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1 [message #489650] Mon, 05 October 2009 09:36 Go to next message
Eclipse UserFriend
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 #490052 is a reply to message #489650] Wed, 07 October 2009 01:42 Go to previous messageGo to next message
Eclipse UserFriend
For the render option use code similar to the following:

IRenderOption options = new RenderOption();
options.setOutputFormat("pdf");
options.setOutputStream(...");


if( options.getOutputFormat().equalsIgnoreCase("html")){
HTMLRenderOption htmlOptions = new HTMLRenderOption( options);
htmlOptions.setImageDirectory("output/image");
//set this if you want your image source url to be altered
//htmlOptions.setBaseImageURL("http://myhos/prependme?image=");
htmlOptions.setHtmlRtLFlag(false);
htmlOptions.setEmbeddable(false);
}else if( options.getOutputFormat().equalsIgnoreCase("pdf") ){

PDFRenderOption pdfOptions = new PDFRenderOption( options );
/* CLIP_CONTENT: clip the content
* FIT_TO_PAGE_SIZE: scale the content to fit into the page
* OUTPUT_TO_MULTIPLE_PAGES: divided the content into multiple pages
* ENLARGE_PAGE_SIZE: enlarge the page size to contain all the content.
*/
pdfOptions.setOption( IPDFRenderOption.PAGE_OVERFLOW, Integer.valueOf( PDFRenderOption.FIT_TO_PAGE_SIZE ) );

}

task.setRenderOption(options);

Jason
Re: Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1 [message #490053 is a reply to message #489650] Wed, 07 October 2009 01:44 Go to previous messageGo to next message
Eclipse UserFriend
Do not use this code:

RenderContext pdfCtx = new RenderContext(new ExecutionContext());
HashMap<String, RenderContext> pdfContextMap = new HashMap<String, RenderContext>();
pdfContextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONT EXT,
pdfCtx);
task.setAppContext(pdfContextMap);

Jason
Re: Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1 [message #490338 is a reply to message #489650] Thu, 08 October 2009 08:05 Go to previous messageGo to next message
Eclipse UserFriend
After some debugging i found, that on executing task.run() the
DataEngine is NULL. ExecutionContext.openDataEngine() catchs a
BirtException 'no such extension: javascript'.

I've installed BIRT with the Eclipse Package-Manager.
Is there anything else to install?

Ralf
Re: Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1 [message #490360 is a reply to message #490338] Thu, 08 October 2009 08:31 Go to previous messageGo to next message
Eclipse UserFriend
Hello Ralf, hello Jason,

I want to inform you that I have the same problem upgrading from BIRT 2.3 to
2.5.1. and I confirm the analysis of Ralf.

It seems that the problem only occurs if the upgrade was made with the
eclipse update manager.

If I download the plugins of Birt 2.5.1 and its depending projects and put
them as "dropins" into eclipse 3.5.1 then the report generation works fine.
Therefore I don't think that my code to create the report has a general
problem with BIRT 2.5.1.

It would be wonderful to get a solution/workaround because we are few days
before release date and our customers should also be able to use the eclipse
update manager...

Thanks in advance,
Gerald.
Re: Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1 [message #490482 is a reply to message #490360] Thu, 08 October 2009 15:12 Go to previous messageGo to next message
Eclipse UserFriend
Hi Gerald,

i did not try the dropin. What I've done is an upgrade of the Postgresql
JDBC, what we used for the Reports. As I tried to preview the reports in
the Report Designer I get some strange errors concerning the JDBC. After
upgrading the jdbc from 8.1 to 8.4, preview and RCP now works. Seems to
me that BIRT 2.5 requires this newer Version.

Don't know if you use Postgres, but hope this helps.

Gruss
Ralf

Gerald Ploner schrieb:
> Hello Ralf, hello Jason,
>
> I want to inform you that I have the same problem upgrading from BIRT 2.3 to
> 2.5.1. and I confirm the analysis of Ralf.
>
> It seems that the problem only occurs if the upgrade was made with the
> eclipse update manager.
>
> If I download the plugins of Birt 2.5.1 and its depending projects and put
> them as "dropins" into eclipse 3.5.1 then the report generation works fine.
> Therefore I don't think that my code to create the report has a general
> problem with BIRT 2.5.1.
>
> It would be wonderful to get a solution/workaround because we are few days
> before release date and our customers should also be able to use the eclipse
> update manager...
>
> Thanks in advance,
> Gerald.
>
>
Re: Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1 [message #490539 is a reply to message #490482] Fri, 09 October 2009 01:47 Go to previous messageGo to next message
Eclipse UserFriend
Gerald,

Can you open a bug for the update manager problem?
Also in the bug can you specify if this was for an RCP application or just using the designer.

Jason
Re: Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1 [message #490638 is a reply to message #490539] Fri, 09 October 2009 10:17 Go to previous messageGo to next message
Eclipse UserFriend
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.
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 Go to previous messageGo to next message
Eclipse UserFriend
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.
>
>
Re: Problems with ReportEngine after Upgrading Birt from 2.3 to 2.5.1 [message #491071 is a reply to message #490958] Tue, 13 October 2009 03:07 Go to previous message
Eclipse UserFriend
Hello Jason,

I created a bugzilla entry (Bug 292109).

Thank you for spending some of your time with our problem.

Best regards,
Gerald.
Previous Topic:Mixed-page render performance
Next Topic:how to improve performance
Goto Forum:
  


Current Time: Thu May 22 08:31:30 EDT 2025

Powered by FUDForum. Page generated in 0.12450 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top