I am deploying a web services on WSO2 Application Server 5.2.1 which loads a reportDesign from a database table and renders a PDF stream, which is then stored as a file in an outgoing ftp server directory. All works well when running from the command line, but I am having a hard time configuring the EngineConfig's EngineHome property in when deploying on WSO2 AS 5.2.1.
My pom.xml file (for Maven) embeds Birt 4.4.1 runtime in my aar file, which is then deployed as part of a larger car file. Birt jar files are correctly picked up by my web service.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
....
<artifactItem>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.4.1</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/aar/lib</outputDirectory>
</artifactItem>
...
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
<dependencies>
...
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.4.1</version>
</dependency>
...
</dependencies>
A snippet of my Java code is as follows, which has been stripped down for simplicity:
InputStream theReportDesign = getReportDesignStream();
// The engine will eventually be called just once...
EngineConfig config = new EngineConfig();
config.setEngineHome("");
// Create the report engine itself. This engine can be used to run
// multiple reports.
ReportEngine engine = new ReportEngine(config);
// Create a task to run the report and convert the output to PDF.
IReportRunnable report = engine.openReportDesign(theReportName, theReportDesign);
IRunAndRenderTask task = engine.createRunAndRenderTask(report);
outputStream = new ByteArrayOutputStream();
// Define the report generation options
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);
options.setOutputStream(outputStream);
task.setRenderOption(options);
task.setErrorHandlingOption(IEngineTask.CONTINUE_ON_ERROR);
// set the parameters to appear in the report
task.setParameterValues(values);
// Generate the report.
task.run();
// Write the report to disk, so ftp clients can pick it up
outputStream.close();
writePdfReportToFile(outputStream);
The error I get when running this from within WSO2 Application Server is as follows:
Can not load the report engine
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.ReportEngine.openReportDesign(ReportEngine.java:182)
I have seen many proposed solutions on the web, but most within the Tomcat/Axis2 environment (which is what WSO2 uses) require knowledge of the ServletContext. My attempts to get the ServletContext off of the MessageContext have not been successful.
I am hoping to not have to deploy Birt into WSO2, but to instead keep the Birt Runtime contained within my aar file which I deploy to WSO2. But I'll resort to deploying Birt directly to the WSO2 server, as well (just need instructions to do that and still make the above code work).
Thanks in advance for any help.