Posted by: Brian de Alwis | July 6, 2011

Debugging BIRT

I’ve recently been doing some client work with BIRT reports. Although BIRT is a surprisingly powerful reporting framework with support for embedding JavaScript, debugging a failing report is a bear. Unfortunately I have yet to find a nice compendium of debugging advice.

So without further ado, here are some tips and tricks I’ve stumbled across. I’ll amend this post with updates. Feel free to contribute your own in the comments!

[Updated 2011/07/21: add note about EngineException]

Debugging Problems in JavaScript Code

BIRT uses the Mozilla Rhino execution engine to process its JavaScript. To trap various JavaScript errors, place breakpoints on the following exceptions:

  • org.mozilla.javascript.RhinoError
  • org.mozilla.javascript.EcmaError: thrown on missing methods
  • org.mozilla.javascript.EvaluatorException
  • org.mozilla.javascript.JavaScriptException
  • org.mozilla.javascript.RhinoException

I’ve found that it’s also useful to put a breakpoint on org.eclipse.birt.report.engine.api.EngineException as this seems to be thrown when there is a calculation error of some kind within the report. If you’re getting an error displayed like:

Errors occurred when generating the report document for the report element with 2906

then you’re likely encountering an NPE or division-by-zero error in your JavaScript code.

org.eclipse.birt.report.engine.api.ViewerException is thrown when there’s some deeper issue affecting report generation.

ViewerException: The viewing session is not available or has expired

The system that I’m developing uses a web interface to view BIRT reports. I found that during development that the report generation would fail, complaining that “The viewing session is not available or has expired”. It turns out that although I was accessing the web interface through “localhost”, internally the system would redirect to the machine’s alternative name “dev.mt.ca”. As my browser was configured to ignore cookies from other domains, the BIRT session cookies were tossed.

All was well when I accessed the web interface using the alternative machine name.

EngineException: Can not load the report query

I’ve usually seen this exception in a few circumstances:

  • When binding a table to a dataset and specifying a column that no longer exists. “Refreshing” a table’s bindings only adds missing columns; there’s no warnings of bad references. (I wonder if there’s a way to trap references to non-existant columns?)
  • Having changed a table grouping’s name, but forgetting to update any aggregations defined by that grouping name.
Advertisements

Responses

  1. […] Read the rest here: Brian de Alwis: Debugging BIRT […]

  2. Hi Brian,
    Here are couple of suggestions for debugging BIRT:
    http://www.birt-exchange.org/org/devshare/designing-birt-reports/1170-using-a-popup-debug-window-in-birt/
    http://www.eclipse.org/birt/phoenix/project/notable2.3M5.php#jump_2

    You may also submit your BIRT tips on BIRT Exchange devshare (http://www.birt-exchange.org/org/devshare/) so more BIRT developers can benefit from your findings.

    • Thanks Ashwini. In my case these reports rely on Java-based model objects to populate the report content. I wonder if it’s possible to hook in the JavaScript debugger from an invoked report…


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories