Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Eclipse's BIRT: Update from 2.6.2 (OSGI) to 4.3.1 (POJO)

DZone's Guide to

Eclipse's BIRT: Update from 2.6.2 (OSGI) to 4.3.1 (POJO)

· Big Data Zone ·
Free Resource

How to Simplify Apache Kafka. Get eBook.

In an Java application eclipse's BIRT in the version 2.6.2 (as runtime version) is used as report engine for some years and needed to be updated. Because the 2.6.2 version runs as OSGI platform (like eclipse) and all BIRT versions afterwards are loaded as POJO the update itself in not trivial nor intuitive and can be regarded as a kind of migration.

After successfull BIRT update I want to present the source were the hints for this taks can be found. Also some problems and their solutions which I had during and after the update process will be described here.

Doing the update several question were open include:

What is the main difference between the version?
The ReportEngine folder is no needed anymore and if you are using maven you can bound the BIRT runtime binaries via maven dependency.

Are the report which were created with the old version files (library, design, template) compatible with the new BIRT?
The reports can be used in the newest version of BIRT but some changes must be done. Later in this article I will write more about this.

How the custom report items can be bound, set on the classpath, to the application?
The custom report items should be set on the classpath as if they were plain jar libraries. In this article I want to mention how they can be "mavenized".

How about the fonts? Since there is not ReportEngine folder in the POJO anymore where the fonts can be defined and how they can be bound to the application.
Via system property a path to the font folder can be set so the PDF emmiter (iText[ref] wrapper). This way the generated PDF's use the custom fonts even if they are not installed on the host system.

General Changes

Main Guide

The main guide for updating the OSGI to the POJO BIRT version can be found on the eclipse wiki page [ref]. One of the main changes is the config method call in Java where the BIRT home parameter is not needed any more since the "ReportEngine"-folder within its plugins is omitted. These sources can be set on classpath from a lib folder or i.e. with maven.

<dependency>
	<groupId>org.eclipse.birt.runtime</groupId>
	<artifactId>org.eclipse.birt.runtime</artifactId>
	<version>4.3.1</version>
</dependency>

Fonts

If the PDF emmiter, the library module for exporting PDF files, uses fonts which are not installed on the host system in the previous version of BIRT you needed to declare and copy them in the font plugin folder. In the POJO version of BIRT you can declare them directly on the emmiter (iText class) setting the right font path to the system property ("birt.customfontsdir").

String customFontsDirPath = System.getProperty("birt.customfontsdir");
if(customFontsDir != null){
	FontFactory.registerDirectory(customFontsDirPath);
}

About this approch you can read more from the bugzilla comments [ref].

Report Library Changes

Page Break Intervall

One change that must be done is setting the page break intervall value from 0 to 10000. In the 2.6.2 BIRT version the value "0" meant no page break at all but in the new version of BIRT this value produces error log outputs. From the buzilla ticket [ref] you can see the discussion about this issue. The question is was would happend if the list or table has more rows than 10000. Propably an page break will be produced which is not requested here.

Page Break Header Problem

An interesting behavior came with the new BIRT version. If a table has a header which has given height and the "reapeat header" was "on" some of the headers were done on the next page.This problem I could only avoid by deleting the static height leaving the height text box empty.

Also if a header has no elements in it, it is not repeated on the next page. I needed to define dummy text item with "&nbsp;" in it so this header is visible on any next page.

This proposals are only fast workarounds for the give situations.

Line Height

The default line height also changed and its less higher in the new version of BIRT then before. If you need the old line hight that you can do this by using CSS and bound it as part of the default theme of the report design or library file. From the BIRT world blog  you can learn how to use css which can manipulate globally i.e. all text items layout [ref]. In this case the CSS could look like:

.text {
	line-height: 1.3em;
}

Custom Report Items

Setting the report items on classpath

The custom report items are eclipse plug-ins which are used in BIRT since BIRT is a plug-in project too. To use them in the report designer they need to be plugins, but for the POJO BIRT version need to be bound as casual POJO jars. They can be set on the classpath from any folder or i.e. bound via maven. To create the eclipse plug-ins (custom report items) as maven artifacts extra plugins are needed. One approach to do this is to use tycho [ref]. About using tycho I can recommend Lars Vogel Tutorial page [ref]. After deploying them on your maven server you can use them the same way as any other jar via maven dependency.

Using images from the report item

If you are using images in the report items and loading the via the FileLocator.find method then this wont work on runtime since the jars are not loaded in a OSGI environment (declared on the server as service). Instead of that the casual class.getResource should be used.

// In the plugin the image folder is on the project most higher level (project root)
URL imageUrl = null;
if (Platform.getBundle("org.eclipse.birt.report.extension.myreportitem") != null) {
	//when load as BIRT OSGI plug-in
	imageUrl = FileLocator.find(Platform.getBundle("org.eclipse.birt.report.extension.myreportitem"), new Path("image/myimage.svg"), null);
} else {
	//when load as BIRT POJO
	imageUrl = MyRenderClass.class.getResource("/image/myimage.svg");
}

Problems by using the plugins on runtime

In the custom report items SVG images as custom charts where returned. The SVG was generated with the xerces parser from eclipse which was in the version 2.9.1. When executing the report an exception was thrown. I think it was method not found exception. After searching on the internet about this issue got many solutions which not helped me (they were about downgrading the xerces parser ur using other transformation classes which were deprecated). This error had to do with the TransformationInstance class which is used at the end of the SVG creation. The solution in my case was to use the newest version of xalan (2.7.1) parser in hope it will be used instead of the parser version which is used by Java. 

<dependency>
	<groupId>xalan</groupId>
	<artifactId>xalan</artifactId>
	<version>2.7.1</version>
</dependency>

Other problems

Several times i needed to "rebound" a data set to a table or list. It seems that the new BIRT version has problems when some unexpected situation came like:

  • using float data item when the value is empty string
  • empty or null value in a expression (Javascript part)

In this case the whole content is not visible and much more interesting fact is that there is no error output at all even not in the log files while the log level is set on warning.

Résumé

In this article I wanted to present my experiense of updating BIRT used as runtime version on a Java applicaton from 2.6.2 as OSGI platform to 4.3.1 bound as library like POJO. Doing this I gathered knowledge about this approach from many sites which I have referenced here in this article. During the update several problems occured and thier solutions or wourarounds are described here.

12 Best Practices for Modern Data Ingestion. Download White Paper.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}