Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Null pointer exception while creating report engine.
vineethakp
This is my code for combining two reports.
=============================================================================================================
package com.report.test;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Level;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.PDFRenderOption;
public class Combine {
public void runReport() throws BirtException, IOException
{
IReportEngine iReportEngine =null;
EngineConfig engineConfig = null;
try
{
engineConfig = new EngineConfig();
engineConfig.setEngineHome("C:\\birt-runtime-2_6_2\\birt-runtime-2_6_2\\ReportEngine");
System.out.println("Setting Engine Home");
engineConfig.setLogConfig(null, Level.OFF);
Platform.startup(engineConfig);
System.out.println("Platform Started");
IReportEngineFactory iReportEngineFactory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
iReportEngine = iReportEngineFactory.createReportEngine(engineConfig);
System.out.println("Report Engine Created");
}
catch (Exception e) {
e.printStackTrace();
}
IReportRunnable design1 = iReportEngine.openReportDesign("F:\\MyWorkSpace\\Merging\\WebRoot\\reports\\Report_A.rptdesign");
IReportRunnable design2 = iReportEngine.openReportDesign("F:\\MyWorkSpace\\Merging\\WebRoot\\reports\\Report_B.rptdesign");
IRunAndRenderTask iRunAndRenderTask = iReportEngine.createRunAndRenderTask(design1);
FileOutputStream fileOutputStream1 = new FileOutputStream("C/output/combined.pdf", true);
PDFRenderOption pdfRenderOption = new PDFRenderOption();
pdfRenderOption.setOutputStream(fileOutputStream1);
pdfRenderOption.setOutputFormat("PDF");
iRunAndRenderTask.setRenderOption(pdfRenderOption);
iRunAndRenderTask.run();
iRunAndRenderTask = iReportEngine.createRunAndRenderTask(design2);
FileOutputStream fileOutputStream2 = new FileOutputStream("C/output/combined.pdf", true);
pdfRenderOption.setOutputStream(fileOutputStream2);
iRunAndRenderTask.setRenderOption(pdfRenderOption);
iRunAndRenderTask.run();
fileOutputStream1.flush();
fileOutputStream2.flush();
fileOutputStream1.close();
fileOutputStream2.close();
iRunAndRenderTask.close();
iReportEngine.destroy();
Platform.shutdown();
System.out.println("Finished");
}
public static void main(String args[]) throws FileNotFoundException, BirtException
{
try {
Combine combine = new Combine();
combine.runReport();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
=============================================================================================================
But i am getting this Exception.
java.lang.NullPointerException
at org.eclipse.birt.report.engine.api.impl.ReportEngine$EngineExtensionManager.<init>(ReportEngine.java:784)
at org.eclipse.birt.report.engine.api.impl.ReportEngine.<init>(ReportEngine.java:109)
at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory$1.run(ReportEngineFactory.java:18)
at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory$1.run(ReportEngineFactory.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory.createReportEngine(ReportEngineFactory.java:14)
at com.report.test.Combine.runReport(Combine.java:33)
at com.report.test.Combine.main(Combine.java:74)
java.lang.NullPointerException
at com.report.test.Combine.runReport(Combine.java:40)
at com.report.test.Combine.main(Combine.java:74)
If my code is perfect. Please tell me in detail what jars should be copied to my workspace lib from birt-runtime.
Find more posts tagged with
Comments
There are no comments yet