Monday, November 3, 2008

Birt Reporting Tool

I will document all my experience with Birt reporting tool:
Some facts about Birt - Birt is a reporting tool integrated with Java. - Birt saves the report design in xml format. - There's a lot of APIs come with Birt used to integrate with Birt to develop custom designer or custom engine. - Birt very primitive reporting tool with limited out of the box features, but it include a lot of APIs make it extensible.
Where to start? - You need Eclipse IDE to with Birt plug-ins , and you can download it from the URL below: http://www.eclipse.org/downloads/download.php?file=/birt/downloads/drops/R-R1-2_3_1-200809221151/birt-report-designer-all-in-one-2_3_1.zip
- Download the Birt Runtime Engine from: http://www.eclipse.org/downloads/download.php?file=/birt/downloads/drops/R-R1-2_3_1-200809221151/birt-runtime-2_3_1.zip And extract it to: C:/birt-runtime-2_3_1/
- Then you should extract this file.
- Now you can open Eclipse IDE and design you first report.
- There’s a very useful tutorial on Eclipse site to design simple Birt report: http://www.eclipse.org/birt/phoenix/tutorial/basic/
Integration Examples
- I found very useful examples that demonstrate the integration points and capabilities with Birt runtime engine.
1. Java – Simple Design Engine http://wiki.eclipse.org/Java_-_Simple_Design_Engine_API_%28BIRT%29
this example show how to develop a custom report designer.
When you go through this example don’t forget the below: a. Make sure that Eclipse reference to the correct JDK: Window => Preferences ==>Java==>Installed JREs Window ==> Preferences ==>Java==>Compiler
b. Make sure that your project reference the Birt packages Right click your project ==> Properties ==> Java Build Path==>libraries. If there’s any exception fire to you try to add from “Add External JARs” I add reference to the below JARs: o eclipse/plugins/com.ibm.icu_3.8.1.v20080530.jar o eclipse/plugins/org.eclipse.birt.report.model_2.3.1.v20080912.jar" o eclipse/plugins/org.eclipse.birt.report.runtime_2.3.1.v20080701.jar o eclipse/plugins/org.eclipse.birt.core.ui_2.3.1.v20080807.jar o eclipse/plugins/org.eclipse.birt.core_2.3.1.v20080912.jar o eclipse/plugins/org.eclipse.birt.report.designer.core_2.3.1.v20080911.jar o eclipse/plugins/org.eclipse.birt.report.designer_2.3.1.v20080701.jar o eclipse/plugins/org.apache.commons.codec_1.3.0.v20080530-1600.jar o eclipse/plugins/org.eclipse.birt.data_2.3.1.v20080829.jar o eclipse/plugins/org.w3c.css.sac_1.3.0.v200805290154.jar o eclipse/plugins/org.mozilla.rhino_1.6.7.v20080214/lib/js.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/chartengineapi.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/com.ibm.icu_3.8.1.v20080530.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/commons-cli-1.0.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/coreapi.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/crosstabcoreapi.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/dataadapterapi.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/dataaggregationapi.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/dataextraction.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/dteapi.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/engineapi.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/flute.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/js.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/modelapi.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/modelodaapi.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/odadesignapi.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/org.apache.commons.codec_1.3.0.v20080530-1600.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/org.eclipse.emf.common_2.4.0.v200808251517.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/org.eclipse.emf.ecore.xmi_2.4.1.v200808251517.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/org.eclipse.emf.ecore_2.4.1.v200808251517.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/org.w3c.css.sac_1.3.0.v200805290154.jar o C:/birt-runtime-2_3_1/ReportEngine/lib/scriptapi.jar o eclipse/plugins/org.apache.derby.core_10.3.1.4/derby.jar
c. don’t forget to change this code line in the class sample to reference the Birt runtime engine: config.setProperty("BIRT_HOME", "C:/birt-runtime-2_1_1/birt-runtime-2_1_1/ReportEngine"); Replace it to config.setProperty("BIRT_HOME", "C:/birt-runtime-2_3_1//ReportEngine");
d. create this folder on C root to because the sample render the generated report inside this folder c:/tmp/
e. Now you can run the sample. Enjoy ;)
2. Java - Execute Modified Report (BIRT) http://wiki.eclipse.org/Java_-_Execute_Modified_Report_%28BIRT%29
This example show how to execute existing report and generate data report with any format (HTML, pdf … etc)
3. Using the BIRT Report Viewer http://www.eclipse.org/birt/phoenix/deploy/viewerSetup.php
This example show how to use the report viewer, it works with me only when I install Apache web server 5.5: http://tomcat.apache.org/download-55.cgi

Conclusion: - You can modify the existing reports designed with Eclipse IDE or by editing the report XML file (but don’t forget to take a backup before editing J) - You can get the report result by: o By executing the existing report through Birt APIs. o Run the report directly through a JSP application. o Use the report viewer in a JSP or PHP application. - You can build your own designer or engine by using the APIs.

Created By

Ahmed Abdel Moneim

Sunday, November 2, 2008

Java - Simple Design Engine API (BIRT)

Error: When try to run the java application that use the Birt APIs it gave the below error:
org.eclipse.birt.core.exception.BirtException: Cant startup the OSGI framework
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:91)
at DECreateDynamicTable.buildReport(DECreateDynamicTable.java:109)
at DECreateDynamicTable.main(DECreateDynamicTable.java:45)
Caused by: org.eclipse.birt.core.exception.BirtException: Could not start the Framework - C:/birt-runtime-2_1_1/birt-runtime-2_1_1/ReportEngine
at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:87)
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:79)
... 2 more
Exception in thread "main" java.lang.NullPointerException
at DECreateDynamicTable.buildReport(DECreateDynamicTable.java:119)
at DECreateDynamicTable.main(DECreateDynamicTable.java:45)


Cause: because the Birt_Home variable in configration object not refer to the Birt Engine Path correctly.

Resolution: Locate the below code line and correct the path
config.setProperty("BIRT_HOME", "C:/birt-runtime-2_3_1/ReportEngine");


Created By
Ahmed Abdel Moneim