-
Hello, I'm new to BIRT. I'm working on porting an old project to Spring Boot 3.4. In the old project, we used many BIRT reports to generate XLS and PDF files. The idea is to reuse the existing reports in the new application. Is the latest version of BIRT compatible with Spring Boot 3.4 and Java 17? I saw ZIP files with dependencies on the download page, but it's not clear to me where to find the specific dependencies I need. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 28 replies
-
The BIRT 4.20 is compatible with Java 17 and the upcoming version 4.21 with Java 21. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply, @speckyspooky. I downloaded the runtime from this link: Inside the lib directory, I see plenty of JAR files, but I assume not all of them are necessary. |
Beta Was this translation helpful? Give feedback.
-
They are not all exactly necessary, but you'll have a hard time to sort them out. I did this in a different way (by modifying the BIRT sources and In addition, you'll need the Oracle JDBC driver, I don't use Spring Boot, so I cannot help you in this regard. |
Beta Was this translation helpful? Give feedback.
-
For designing reports, it is a lot easier to use the birt-designer-all-in-one. |
Beta Was this translation helpful? Give feedback.
-
Maybe your report uses features which are no longer supported, eg. Adobe Flash? Please create a |
Beta Was this translation helpful? Give feedback.
-
Ok, I figured out what the problem is. ![]() If you remove the item your report will work: error-free-report_cmds_2.rptdesign.txt The other problem is that the report engine doesn't handle the empty item in a correct way. So I will create a fix of it. |
Beta Was this translation helpful? Give feedback.
-
I know it existed somewhere. But I never used it. Our company licenced a different Java barcode library ~ 25 years ago (for Oracle Reports at that time) and we generate barcodes by calling this library through Javascript, creating image content as a byte array. For adding a QR code plugin, I had started PRs once, the latest one was #1087, but I wasn't satisfied with the scripting integration and abandoned the PR, together with a hint how to generate QR code with script in the comments. Generally It has become a bit more difficult to use scripting for generating images due to Java's module system, see #1138. Maybe this dicussion should be split, because the topic drifts away form invalid extended items to barcode generation. |
Beta Was this translation helpful? Give feedback.
-
Thanks for all the support! This is my working solution, which might be useful for others. Integration of BIRT 4.20 in a Spring Boot 3.4 projectFeatures
BIRT IDESince I use IntelliJ, I preferred the all-in-one BIRT solution to avoid installing and configuring a separate Eclipse environment. Oracle Database ConnectionTo connect to an Oracle database from BIRT IDE, you need to add the Oracle JDBC driver to the datasource configuration. In order to use the thin driver, you need to pass the tnsnames.ora file as a VM argument.
Now you can use a jdbcurl like: Maven Dependencies<!-- Core -->
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.core</artifactId>
<version>4.20.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.report.engine</artifactId>
<version>4.20.0</version>
</dependency>
<!-- Emitter PDF -->
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.report.engine.emitter.pdf</artifactId>
<version>4.20.0</version>
</dependency>
<!-- Emitter Excel -->
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>uk.co.spudsoft.birt.emitters.excel</artifactId>
<version>4.20.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.report.engine.emitter.prototype.excel</artifactId>
<version>4.20.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.report.engine.emitter.config.excel</artifactId>
<version>4.20.0</version>
</dependency>
<!-- Data Engine -->
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.data</artifactId>
<version>4.20.0</version>
</dependency>
<!-- ODA JDBC Driver -->
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.report.data.oda.jdbc</artifactId>
<version>4.20.0</version>
</dependency>
<!-- Model API -->
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.report.model</artifactId>
<version>4.20.0</version>
</dependency>
<!-- Chart Engine -->
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.chart.engine</artifactId>
<version>4.20.0</version>
</dependency>
<!-- JavaScript Support -->
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.core.script.function</artifactId>
<version>4.20.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.report.engine.script.javascript</artifactId>
<version>4.20.0</version>
</dependency>
<!-- Additional BIRT Dependencies -->
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.data.aggregation</artifactId>
<version>4.20.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.report.data.adapter</artifactId>
<version>4.20.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.chart.reportitem</artifactId>
<version>4.20.0</version>
</dependency>
<!-- BIRT Barcode and QR-code -->
<!-- This dependency is not present on Maven Central, just on local nexus.
Project site: https://code.google.com/archive/p/birt-barcode-extension/
-->
<dependency>
<groupId>de.c-brell.birt.reportitem</groupId>
<artifactId>barcode</artifactId>
<version>1.0.1.201205022021</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.5.3</version>
</dependency> Barcode and QR Code SupportI used the birt-barcode-extension for compatibility with older reports that I didn’t want to modify. I assume there are newer and better alternatives available. The main dependency The ZIP contains both runtime JARs for the application and plugin JARs for the BIRT IDE (or Eclipse, depending on your setup).
Once the plugin JARs are added to the BIRT IDE, you’ll see a new item called BarcodeItem under the Report Items section in the Designer. JUnit TestHere’s a simple test class to generate PDF and XLSX reports: import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.*;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
@Slf4j
class BirtTest {
private static final String REPORT_DIR = "src/main/resources/birt-reports/";
private static final String OUT_DIR = "src/test/out/";
private static final String JDBC_URL = "...";
private static final String USER = "...";
private static final String PSW = "...";
@SneakyThrows
@Test
void testMyPdfReport() {
String reportName = "myPdfReport";
Map<String, Object> params = new HashMap<>();
params.put("...", "...");
testPdf(reportName, params);
}
@SneakyThrows
@Test
void testExcelReport() {
String reportName = "myExcelReport";
Map<String, Object> params = new HashMap<>();
params.put("...", "...");
testXLS(reportName, params);
}
@SneakyThrows
void testPdf(String reportName, Map<String, Object> params) {
log.info("Testing report with Oracle connection");
// Startup of Birt platform
final EngineConfig config = new EngineConfig();
Platform.startup(config);
final IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
IReportEngine birtEngine = factory.createReportEngine(config);
birtEngine.changeLogLevel(Level.WARNING);
// Load the report design
var reportPath = REPORT_DIR+reportName+".rptdesign";
IReportRunnable runnable = birtEngine.openReportDesign(reportPath);
// Create the rendering task
IRunAndRenderTask task = birtEngine.createRunAndRenderTask(runnable);
// Configure Oracle database connection
Map<String, Object> appContext = new HashMap<>();
try {
// Create JDBC connection
Connection connection = DriverManager.getConnection(JDBC_URL, USER, PSW);
log.info("Oracle connection established successfully");
// Set connection in application context
appContext.put("OdaJDBCDriverPassInConnection", connection);
task.setAppContext(appContext);
// Validate report parameters before setting them
try {
// Set report parameters
if (params != null) {
for (Map.Entry<String, Object> entry : params.entrySet()) {
task.setParameterValue(entry.getKey(), entry.getValue());
log.info("Parameter set: " + entry.getKey() + " = " + entry.getValue());
}
} else {
log.warn("No parameters provided for report " + reportName);
}
// Validate parameters
task.validateParameters();
log.info("Parameters validated successfully");
} catch (Exception paramEx) {
log.warn("Error setting parameters: " + paramEx.getMessage());
// Continue without parameters if there's an error
}
// Configure rendering options
ByteArrayOutputStream outs = new ByteArrayOutputStream();
RenderOption options = new PDFRenderOption();
options.setOutputFormat("pdf");
options.setOutputStream(outs);
task.setRenderOption(options);
// Execute the report
log.info("Starting report execution...");
task.run();
// Save the generated PDF
FileUtils.writeByteArrayToFile(new File(OUT_DIR+reportName+".pdf"), outs.toByteArray());
log.info("Report generated successfully: "+reportName+".pdf");
// Close resources
task.close();
connection.close();
} catch (Exception e) {
log.error("Error during report generation "+reportName, e);
// Print additional information for debugging
if (task != null) {
var errors = task.getErrors();
if (errors != null && !errors.isEmpty()) {
log.error("BIRT task errors:");
for (Object error : errors) {
log.error("- " + error.toString());
}
}
}
throw e;
} finally {
if (task != null) task.close();
birtEngine.destroy();
Platform.shutdown();
}
}
@SneakyThrows
void testXLS(String reportName, Map<String, Object> params) {
log.info("Testing report with Oracle connection");
// Startup of Birt platform
final EngineConfig config = new EngineConfig();
Platform.startup(config);
final IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
IReportEngine birtEngine = factory.createReportEngine(config);
birtEngine.changeLogLevel(Level.WARNING);
// Load the report design
var reportPath = REPORT_DIR+reportName+".rptdesign";
IReportRunnable runnable = birtEngine.openReportDesign(reportPath);
// Create the rendering task
IRunAndRenderTask task = birtEngine.createRunAndRenderTask(runnable);
// Configure Oracle database connection
Map<String, Object> appContext = new HashMap<>();
try {
// Create JDBC connection
Connection connection = DriverManager.getConnection(JDBC_URL, USER, PSW);
log.info("Oracle connection established successfully");
// Set connection in application context
appContext.put("OdaJDBCDriverPassInConnection", connection);
task.setAppContext(appContext);
// Validate report parameters before setting them
try {
// Set report parameters
if (params != null) {
for (Map.Entry<String, Object> entry : params.entrySet()) {
task.setParameterValue(entry.getKey(), entry.getValue());
log.info("Parameter set: " + entry.getKey() + " = " + entry.getValue());
}
} else {
log.warn("No parameters provided for report " + reportName);
}
// Validate parameters
task.validateParameters();
log.info("Parameters validated successfully");
} catch (Exception paramEx) {
log.warn("Error setting parameters: " + paramEx.getMessage());
// Continue without parameters if there's an error
}
// Configure rendering options for Excel
ByteArrayOutputStream outs = new ByteArrayOutputStream();
// Use generic RenderOption instead of EXCELRenderOption
EXCELRenderOption options = new EXCELRenderOption();
options.setOutputFormat("xlsx");
options.setOutputStream(outs);
// Additional configurations for spreadsheet format
// Documentation of ExcelEmitter properties:
// https://github.com/eclipse-birt/birt/blob/master/engine/uk.co.spudsoft.birt.emitters.excel/src/uk/co/spudsoft/birt/emitters/excel/README.md
options.setOption("ExcelEmitter.DisplayGridlines", Boolean.TRUE);
options.setOption("ExcelEmitter.DisplayZeros", Boolean.TRUE);
options.setOption("ExcelEmitter.AutoColWidthsIncludeTableHeader", Boolean.TRUE);
task.setRenderOption(options);
// Execute the report
log.info("Starting report execution...");
task.run();
// Save the generated file with correct extension
FileUtils.writeByteArrayToFile(new File(OUT_DIR+reportName+".xlsx"), outs.toByteArray());
log.info("Report generated successfully: "+reportName+".xlsx");
// Close resources
task.close();
connection.close();
} catch (Exception e) {
log.error("Error during report generation "+reportName, e);
// Print additional information for debugging
if (task != null) {
var errors = task.getErrors();
if (errors != null && !errors.isEmpty()) {
log.error("BIRT task errors:");
for (Object error : errors) {
log.error("- " + error.toString());
}
}
}
throw e;
} finally {
if (task != null) task.close();
birtEngine.destroy();
Platform.shutdown();
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Regarding Note: The JDBC THIN driver does not use |
Beta Was this translation helpful? Give feedback.
Thanks for all the support! This is my working solution, which might be useful for others.
Integration of BIRT 4.20 in a Spring Boot 3.4 project
Features
BIRT IDE
Since I use IntelliJ, I preferred the all-in-one BIRT solution to avoid installing and configuring a separate Eclipse environment.
However, it's still possible to install the BIRT extension in Eclipse via the Marketplace.
Oracle Database Connection
To connect to an Oracle database from BIRT IDE, you need to add the Oracle JDBC driver to the datasource configuration.
I used
ojdbc7-12.1.0.2.0.jar
.In order to use the thin driver, you ne…