Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » NPE when added chart
NPE when added chart [message #1386676] Thu, 19 June 2014 11:51 Go to next message
Anatoliy Pogorelov is currently offline Anatoliy PogorelovFriend
Messages: 10
Registered: April 2013
Junior Member
Hi,
in my RAP application used BIRT reports. My report is not work when added chart. In BIRT persepcive preview report show good(image 1.png). When report formed from RAP I give NPE. Without chart report show good from RAP application (image 2.png).
What am I doing wrong?

SEVERE: An error happened while running the report. Cause:
java.lang.NullPointerException
at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.processExtendedContent(LocalizedContentVisitor.java:980)
at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.localizeForeign(LocalizedContentVisitor.java:591)
at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.localize(LocalizedContentVisitor.java:176)
at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:37)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:181)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)

My call procedure:
EngineConfig config = null;
IReportEngine engine = null;
IReportRunnable design = null;
IRunAndRenderTask task;
URL url = getReportURL(reportMnemonic);
config = new EngineConfig();
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(config);
InputStream fs = null;
try {
fs = url.openStream();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
design = engine.openReportDesign(fs);
setConnectionProperties(design);
task = engine.createRunAndRenderTask(design);

HTMLRenderOption renderOptions = new HTMLRenderOption();
renderOptions.setOutputFormat(HTMLRenderOption.HTML);
renderOptions.setOutputStream(outputStream);
renderOptions.setImageDirectory(System.getProperty("java.io.tmpdir"));
renderOptions.setSupportedImageFormats("PNG");
HTMLServerImageHandler imageHandler = new HTMLServerImageHandler() {

@Override
public String onCustomImage(IImage image, Object context) {
return registerImage(image, context);
}

@Override
public String onDesignImage(IImage image, IReportContext context) {
super.onDocImage(image, context);
return "/" + registerImage(image, context);
}

@Override
public String onDocImage(IImage image, IReportContext context) {
super.onDocImage(image, context);
return "/" + registerImage(image, context);
}

private String registerImage(IImage image, Object context) {
byte[] imageData = image.getImageData();
ByteArrayInputStream imageDatainputStream = new ByteArrayInputStream(imageData);
String fileName = image.getID();
RWT.getApplicationContext().getResourceManager().register(fileName, imageDatainputStream);
try {
imageDatainputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
return fileName;
}

};
renderOptions.setImageHandler(imageHandler);

task.setRenderOption(renderOptions);

task.run();
task.close();
engine.destroy();
return outputStream;
Re: NPE when added chart [message #1386885 is a reply to message #1386676] Sun, 22 June 2014 13:04 Go to previous messageGo to next message
Anatoliy Pogorelov is currently offline Anatoliy PogorelovFriend
Messages: 10
Registered: April 2013
Junior Member
no ideas?
Re: NPE when added chart [message #1386927 is a reply to message #1386885] Mon, 23 June 2014 07:14 Go to previous messageGo to next message
Heng Li is currently offline Heng LiFriend
Messages: 12
Registered: July 2009
Junior Member
Which birt version do you use?
I read source code of birt 4.3.2, seems the LocalizedContentVisitor.java should not throw out exception at line #980. Maybe the NPE was caused by failure to init chart plugins in your environment.
Re: NPE when added chart [message #1386943 is a reply to message #1386927] Mon, 23 June 2014 08:33 Go to previous messageGo to next message
Anatoliy Pogorelov is currently offline Anatoliy PogorelovFriend
Messages: 10
Registered: April 2013
Junior Member
Yes, version 4.3.2
Re: NPE when added chart [message #1395810 is a reply to message #1386943] Mon, 07 July 2014 12:27 Go to previous message
Łukasz Drąg is currently offline Łukasz DrągFriend
Messages: 10
Registered: July 2009
Junior Member
Hi,
I had a similar problem and found out that I was missing the following dependencies:

org.eclipse.birt.chart.reportitem,
org.eclipse.birt.chart.engine.extension,
org.eclipse.birt.chart.device.extension,


Please check if adding those to your MANIFEST.MF helps you.

regards,
Łukasz
Previous Topic:PDF and barcode generation through iText
Next Topic:Special kind of bar chart - possible in BIRT?
Goto Forum:
  


Current Time: Tue May 26 14:23:56 GMT 2020

Powered by FUDForum. Page generated in 0.03286 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top