<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">The following was originally posted on StackOverflow: <a data-ipb='nomediaparse' href='
http://stackoverflow.com/questions/27836264/wso2-birt-4-4-1-and-maven'>http://stackoverflow.com/questions/27836264/wso2-birt-4-4-1-and-maven</a></p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">
</p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">I am deploying a web service on WSO2 Application Server 5.2.1 which loads a reportDesign definition from a database table, renders a PDF stream, which is then stored as a file in an outgoing ftp server directory. </p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"> </p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">The same code listed below works perfectly for a command line utility environment, but not when deployed to WSO2 Application Server v5.2.1 (which is essentially Axis2)</p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"> </p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">My pom.xml file (for Maven) when deploying to WSO2 embeds Birt 4.4.1 runtime in my aar file, which is then deployed as part of a larger car file. This car file contains the Birt runtime jar, as I have not deployed Birt directly to the WSO2 server. Birt jar files are correctly picked up by my web service, but execution does not get too far.</p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"> </p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">
</p>
<p><build><br>
<plugins><br>
<plugin><br>
<groupId>org.apache.maven.plugins</groupId><br>
<artifactId>maven-dependency-plugin</artifactId><br>
<version>2.8</version><br>
<executions><br>
<execution><br>
<id>copy</id><br>
<phase>package</phase><br>
<goals><br>
<goal>copy</goal><br>
</goals><br>
<configuration><br>
....<br>
<artifactItem><br>
<groupId>org.eclipse.birt.runtime</groupId><br>
<artifactId>org.eclipse.birt.runtime</artifactId><br>
<version>4.4.1</version><br>
<type>jar</type><br>
<overWrite>false</overWrite><br>
<outputDirectory>${project.build.directory}/aar/lib</outputDirectory><br>
</artifactItem><br>
...<br>
</configuration><br>
</execution><br>
</executions><br>
</plugin><br>
...<br>
</plugins><br>
</build><br>
<dependencies><br>
...<br>
<dependency><br>
<groupId>org.eclipse.birt.runtime</groupId><br>
<artifactId>org.eclipse.birt.runtime</artifactId><br>
<version>4.4.1</version><br>
</dependency><br>
...<br>
</dependencies></p>
<div> </div>
<div><span style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">
</span></div>
<div>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">I am getting a NoClassDefFoundError when calling Platform.startup(config), which is a subclass of Throwable, not Exception... so I've modified my code as follows to catch this error.</p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"> </p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">
</p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"> </p>
<p>try {<br>
// The EngineConfig is used to set up engine-wide configuration<br>
// information.<br>
EngineConfig config = new EngineConfig();<br>
// config.setEngineHome("");<br>
config.setLogConfig(null, Level.OFF);<br><br>
if (config.getLogger() != null)<br>
System.out.println("
logger is not null");<br>
if (config.getServletContext() != null)<br>
System.out.println("
servlet context is not null");<br><br>
String engineHome = config.getBIRTHome();<br>
String birtHome = config.getBIRTHome();<br>
System.out.println("
EngineHome = " + engineHome);<br>
System.out.println("
BirtHome = " + birtHome);<br>
System.out.println("
Starting the Birt platform now.");<br>
Platform.startup(config);<br>
System.out.println("
Creating a report engine factory");<br>
IReportEngineFactory reportEngineFactory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);<br><br>
if (reportEngineFactory == null)<br>
System.out.println("
reportEngineFactory is null");<br>
else<br>
System.out.println("
reportEngineFactory is NOT null");<br><br>
// Create the report engine itself. This engine can be used to run<br>
// multiple reports.<br>
System.out.println("
Creating a report engine");<br>
IReportEngine engine = reportEngineFactory.createReportEngine(config);<br>
// ReportEngine engine = new ReportEngine(config);<br><br>
// Create a task to run the report and convert the output to PDF.<br>
IReportRunnable report = engine.openReportDesign(theReportName, theReportDesign);<br><br>
IRunAndRenderTask task = engine.createRunAndRenderTask(report);<br>
outputStream = new ByteArrayOutputStream();<br><br>
// Define the report generation options<br>
HTMLRenderOption options = new HTMLRenderOption();<br>
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);<br>
options.setOutputStream(outputStream);<br>
task.setRenderOption(options);<br>
task.setErrorHandlingOption(IEngineTask.CONTINUE_ON_ERROR);<br><br>
// set the parameters to appear in the report<br>
task.setParameterValues(values);<br><br>
// Run the report.<br>
task.run();<br>
} catch (EngineException e1) {<br>
e1.printStackTrace();<br>
} catch (BirtException e) {<br>
System.out.println("
Got a Birt Exception: " + e.getMessage());<br>
e.printStackTrace();<br>
} catch (java.lang.NoClassDefFoundError e) {<br>
System.out.println("
Got an NoClassDefFoundError: " + e.getMessage());<br>
e.printStackTrace();<br>
} catch (Exception e) {<br>
System.out.println("
Got an Exception: " + e.getMessage());<br>
e.printStackTrace();<br>
} finally {<br>
....<br>
}</p>
<p> </p>
<p><span style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">
</span></p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">The stack trace on the error is as as follows:</p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"> </p>
java.lang.NoClassDefFoundError: com/ibm/icu/util/UResourceBundle<br>
at org.eclipse.birt.core.framework.jar.ServiceLauncher.startup(ServiceLauncher.java:100)<br>
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:75)<br>
at com.looppay.reports.generator.BirtReportGenerator.generatePdfReport(BirtReportGenerator.java:119)<br>
...<br>
Caused by: java.lang.ClassNotFoundException: Class Not found : com.ibm.icu.util.UResourceBundle<br>
at org.apache.axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:92)<br>
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)<br>
at org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:280)<br>
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)<br><p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"> </p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">
</p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"> </p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">But let's also look at the additional config parameters I've printed out:</p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">- EngineHome = null</p>
<p style="color:rgb(0,0,0);font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">- BirtHome = null</p>
<div> </div>
<div> </div>
<div>So... two questions:</div>
<ul><li>Are there Birt runtime dependencies which Maven does not pick up? This would cause my class not found issue with om.ibm.icu.util.UResourceBundle</li>
<li>Is it acceptable for both EngineHome and BirtHome to be null, if the Birt runtime classes are already loaded by the same class loader which loads my custom code?</li>
</ul><div> </div>
<div>Thanks in advance for your help.</div>
</div>