Hey All,<br />
I am trying to get my first app working with BIRT 2.5.2 generating PDF output from a Java app and when I try to use the sample code from the runtime download and several others, I get the a NullPointerException as soon as it hits the createReportEngine call.<br />
<br />
The code I am trying to run is as follows:<br />
<br />
import java.util.logging.Level;<br />
<br />
import org.eclipse.birt.core.framework.Platform;<br />
import org.eclipse.birt.report.engine.api.EmitterInfo;<br />
import org.eclipse.birt.report.engine.api.EngineConfig;<br />
import org.eclipse.birt.report.engine.api.IRenderOption;<br />
import org.eclipse.birt.report.engine.api.IReportEngine;<br />
import org.eclipse.birt.report.engine.api.IReportEngineFactory;<br />
import org.eclipse.birt.report.engine.api.IReportRunnable;<br />
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;<br />
import org.eclipse.birt.report.engine.api.RenderOption;<br />
<br />
<br />
public class ExecuteCvsReport {<br />
<br />
static void executeReport() throws Exception<br />
{<br />
IReportEngine engine=null;<br />
EngineConfig config = null;<br />
<br />
//Configure the Engine and start the Platform<br />
config = new EngineConfig( );<br />
config.setEngineHome( "E:/Development/birt-runtime-2_5_2/ReportEngine" );<br />
//set log config using ( null, Level ) if you do not want a log file<br />
config.setLogConfig(null, Level.FINE);<br />
<br />
//start the Platform to load the appropriate plug-ins<br />
Platform.startup( config );<br />
//get the factory from the platform<br />
IReportEngineFactory factory = (IReportEngineFactory) Platform<br />
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );<br />
//create the engine<br />
engine = factory.createReportEngine( config );<br />
engine.changeLogLevel( Level.WARNING );<br />
<br />
<br />
//Open a report design - use design to modify design, retrieve embedded images etc. <br />
IReportRunnable design = engine.openReportDesign("reports/csvTest.rptdesign"); <br />
<br />
//Create task to run the report - use the task to execute and run the report,<br />
IRunAndRenderTask task = engine.createRunAndRenderTask(design); <br />
<br />
//INFO: to see if your emitter is available.<br />
// the emitter needs to be in a jar file in the following location<br />
// $BIRT_RUNTIME_HOME/ReportEngine/plugins<br />
// I have found that the name of the jar is not important.<br />
System.out.println("EMITTERS");<br />
EmitterInfo[] emitters = engine.getEmitterInfo();<br />
String emitterId = "";<br />
for (int i = 0; i < emitters.length; i++)<br />
{<br />
System.out.println(emitters
.getFormat());<br />
if ("CVS".equalsIgnoreCase(emitters.getFormat())){<br />
emitterId = emitters.getID();<br />
System.out.println("ID = " + emitterId);<br />
}<br />
<br />
}<br />
System.out.println("FORMATS");<br />
String[] formats = engine.getSupportedFormats();<br />
for (int i = 0; i < formats.length; i++)<br />
{<br />
System.out.println(formats);<br />
}<br />
<br />
// Create a render option and setup appropriately<br />
IRenderOption cvsOption = new RenderOption();<br />
cvsOption.setOutputFormat("CVS");<br />
cvsOption.setOutputFileName("test_cvs.cvs");<br />
task.setRenderOption(cvsOption);<br />
<br />
//task.setRenderOption(cvsOption);<br />
task.setEmitterID(emitterId);<br />
<br />
<br />
//run the report and destroy the engine<br />
task.run();<br />
task.close();<br />
// Shut down the engine.<br />
engine.shutdown();<br />
Platform.shutdown(); <br />
System.out.println("We are done!!!");<br />
} <br />
/**<br />
* @param args<br />
*/<br />
public static void main(String[] args) {<br />
try<br />
{<br />
executeReport( );<br />
}<br />
catch ( Exception e )<br />
{<br />
e.printStackTrace();<br />
}<br />
}<br />
<br />
}<br />
<br />
The full error I get is as follows:<br />
<br />
java.lang.NullPointerException<br />
at org.eclipse.birt.report.engine.api.impl.ReportEngine$EngineExtensionManager.<init>(ReportEngine.java:784)<br />
at org.eclipse.birt.report.engine.api.impl.ReportEngine.<init>(ReportEngine.java:109)<br />
at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory$1.run(ReportEngineFactory.java:18)<br />
at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory$1.run(ReportEngineFactory.java:1)<br />
at java.security.AccessController.doPrivileged(Native Method)<br />
at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory.createReportEngine(ReportEngineFactory.java:14)<br />
at ExecuteCvsReport.executeReport(ExecuteCvsReport.java:43)<br />
at ExecuteCvsReport.main(ExecuteCvsReport.java:100)<br />
<br />
I have searched extensively and not found anything that helps with the problem, so any thoughts would be greatly appreciated.<br />
<br />
Thanks,<br />
Ed