Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356833 - ReportDesignHandle.saveAs(..) throws Exception: Message 22868, Cause null
Summary: ReportDesignHandle.saveAs(..) throws Exception: Message 22868, Cause null
Status: CLOSED WORKSFORME
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.6.2   Edit
Hardware: PC Linux
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Birt-Report-inbox@eclipse.org CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-06 12:09 EDT by Susana Domingos CLA
Modified: 2011-09-14 05:45 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Susana Domingos CLA 2011-09-06 12:09:51 EDT
Build Identifier: Version: Helios Service Release 2, Build: 20110218-0911

Hi.

This happens once every couple of hundreds of rendered PDF..
 
I'm developing a multi-threaded java 6 solution on SuSE 11. Each thread works its way through the data, builds a report based on its own template and somewhere along the way saves that template with a couple of changes.
 The code goes like this:
 ...
 ReportDesignHandle reportDesign = null;
 ...
 reportDesign = session.openDesign(thisDesignFile);
 ...
 reportDesign.saveAs(thisDesignFile);
 ...
 
For purpose's sake I might as well add that after populating two embedded images, the final template is rendered to PDF.
 

I've been debugging for the last couple of weeks and have been able to cut way through all I've stubled upon - until now:
 In the midst of tens of data and rendered PDF, one thread, with one specific but not unusual set of data, throws an exception when trying to save the template. Most puzzling is the message associated to the exception: 22868. The cause is null.
 The template is saved, but ill-formed since it's not complete:
 <?xml version="1.0" encoding="UTF-8"?>
 <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22" id="1">
 <property>...</property>
 ...other normal stuff...
 <styles>...</styles>
 <page-setup>...</page-setup>
 <body>...</body>
 <list-property name="images">
 <structure>
 <property name="name">myImage.jpg</property>
 
And that's where it ends; there's nothing wrong with this image, as tens of other reports render it perfectly int their PDF. It is embedd3ed, although, due to rendering problems, I have to load it dynamically again into the template - if not, 5-8% of the times it will be rendered as "Current item is not available".
 
What is Exception 22868?

Stack Print is as follows:
java.lang.ArrayIndexOutOfBoundsException: 22868
 at org.apache.commons.codec.binary.Base64.encode(Base64.java:500)
 at org.apache.commons.codec.binary.Base64.encode(Base64.java:936)
 at org.eclipse.birt.report.model.writer.ModuleWriterImpl.writeEmbeddedImages(ModuleWriterImpl.java:1528)
 at org.eclipse.birt.report.model.writer.DesignWriterImpl.writeImages(DesignWriterImpl.java:217)
 at org.eclipse.birt.report.model.writer.DesignWriterImpl.visitReportDesign(DesignWriterImpl.java:86)
 at org.eclipse.birt.report.model.elements.ReportDesign.apply(ReportDesign.java:65)
 at org.eclipse.birt.report.model.writer.ModuleWriterImpl.writeFile(ModuleWriterImpl.java:314)
 at org.eclipse.birt.report.model.writer.ModuleWriterImpl.write(ModuleWriterImpl.java:282)
 at org.eclipse.birt.report.model.api.ModuleHandleImpl.save(ModuleHandleImpl.java:1440)
 at org.eclipse.birt.report.model.api.ModuleHandleImpl.saveAs(ModuleHandleImpl.java:1460)
 at pt.banif.reporting.engine.BIRTDesignRenderer.call(BIRTDesignRenderer.java:566)
 at pt.banif.reporting.generator.BIRTReportGenerator$DesignRendererConsumer.call(BIRTReportGenerator.java:1284)
 at pt.banif.reporting.generator.BIRTReportGenerator$DesignRendererConsumer.call(BIRTReportGenerator.java:1)
 at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
 at java.util.concurrent.FutureTask.run(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)
 
Is this an org.apache.commons.codec.binary.Base64.encode problem with the image?

The report design template is (with the data snipped):
<?xml version="1.0" encoding="UTF-8"?>
 <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22" id="1">
 <property name="author">me</property>
 <property name="createdBy">Eclipse BIRT Designer Version 2.6.2.r262_v20110209 Build &lt;2.6.2.v20110214-1523></property>
 <property name="units">cm</property>
 <property name="iconFile">path/iconimage.png</property>
 <property name="layoutPreference">fixed layout</property>
 <property name="bidiLayoutOrientation">ltr</property>
 <property name="imageDPI">96</property>
 <list-property name="libraries">
 <structure>
 <property name="fileName">templates/My_PDF.rptlibrary</property>
 <property name="namespace">My_PDF</property>
 </structure>
 </list-property>
 <data-sources>
 <script-data-source name="Data Source" id="146"/>
 </data-sources>
 <data-sets>
 <script-data-set name="Data Set" id="147">
 <structure name="cachedMetaData"/>
 <property name="dataSource">Data Source</property>
 </script-data-set>
 </data-sets>
 <styles>
 <style name="report" id="4">
 <property name="fontFamily">sans-serif</property>
 <property name="fontSize">10pt</property>
 </style>
 <style name="crosstab-cell" id="5">
 <property name="borderBottomColor">#CCCCCC</property>
 <property name="borderBottomStyle">solid</property>
 <property name="borderBottomWidth">1pt</property>
 <property name="borderLeftColor">#CCCCCC</property>
 <property name="borderLeftStyle">solid</property>
 <property name="borderLeftWidth">1pt</property>
 <property name="borderRightColor">#CCCCCC</property>
 <property name="borderRightStyle">solid</property>
 <property name="borderRightWidth">1pt</property>
 <property name="borderTopColor">#CCCCCC</property>
 <property name="borderTopStyle">solid</property>
 <property name="borderTopWidth">1pt</property>
 </style>
 <style name="crosstab" id="6">
 <property name="borderBottomColor">#CCCCCC</property>
 <property name="borderBottomStyle">solid</property>
 <property name="borderBottomWidth">1pt</property>
 <property name="borderLeftColor">#CCCCCC</property>
 <property name="borderLeftStyle">solid</property>
 <property name="borderLeftWidth">1pt</property>
 <property name="borderRightColor">#CCCCCC</property>
 <property name="borderRightStyle">solid</property>
 <property name="borderRightWidth">1pt</property>
 <property name="borderTopColor">#CCCCCC</property>
 <property name="borderTopStyle">solid</property>
 <property name="borderTopWidth">1pt</property>
 </style>
 <style name="f1" id="268">
 <property name="fontFamily">"Lucida Console", "Courier New", "Courier"</property>
 <property name="fontSize">100%</property>
 <property name="fontWeight">bold</property>
 <property name="paddingTop">0px</property>
 <property name="paddingLeft">0px</property>
 <property name="paddingBottom">0px</property>
 <property name="paddingRight">0px</property>
 </style>
 <style name="f2" id="269">
 <property name="fontFamily">"Courier New", "Courier", monospace</property>
 <property name="fontSize">80%</property>
 <property name="fontWeight">normal</property>
 <property name="paddingTop">0px</property>
 <property name="paddingLeft">0px</property>
 <property name="paddingBottom">0px</property>
 <property name="paddingRight">0px</property>
 </style>
 <style name="f3" id="270">
 <property name="fontFamily">"Courier New", "Courier", monospace</property>
 <property name="fontSize">80%</property>
 <property name="fontWeight">bold</property>
 <property name="paddingTop">0px</property>
 <property name="paddingLeft">0px</property>
 <property name="paddingBottom">0px</property>
 <property name="paddingRight">0px</property>
 </style>
 <style name="f4" id="271">
 <property name="fontFamily">"Courier New", "Courier", monospace</property>
 <property name="fontSize">100%</property>
 <property name="fontWeight">normal</property>
 <property name="paddingTop">0px</property>
 <property name="paddingLeft">0px</property>
 <property name="paddingBottom">0px</property>
 <property name="paddingRight">0px</property>
 </style>
 <style name="f5" id="272">
 <property name="fontFamily">"Courier New", "Courier", monospace</property>
 <property name="fontSize">100%</property>
 <property name="fontWeight">bold</property>
 <property name="paddingTop">0px</property>
 <property name="paddingLeft">0px</property>
 <property name="paddingBottom">0px</property>
 <property name="paddingRight">0px</property>
 </style>
 <style name="f7" id="273">
 <property name="fontFamily">"Lucida Console"</property>
 <property name="fontSize">16px</property>
 <property name="fontWeight">normal</property>
 <property name="paddingTop">0px</property>
 <property name="paddingLeft">0px</property>
 <property name="paddingBottom">0px</property>
 <property name="paddingRight">0px</property>
 </style>
 <style name="f8" id="274">
 <property name="fontFamily">"Courier New"</property>
 <property name="fontSize">11px</property>
 <property name="fontWeight">normal</property>
 <property name="paddingTop">0px</property>
 <property name="paddingLeft">0px</property>
 <property name="paddingBottom">0px</property>
 <property name="paddingRight">0px</property>
 </style>
 <style name="my-footer" id="275">
 <property name="fontFamily">"Courier New", "Courier", monospace</property>
 <property name="fontSize">60%</property>
 <property name="fontWeight">normal</property>
 <property name="paddingTop">0px</property>
 <property name="paddingLeft">0px</property>
 <property name="paddingBottom">0px</property>
 <property name="paddingRight">0px</property>
 </style>
 <style name="f-blanks" id="276">
 <property name="fontFamily">"Courier New", "Courier", monospace</property>
 <property name="fontSize">20%</property>
 <property name="fontWeight">normal</property>
 <property name="paddingTop">0px</property>
 <property name="paddingLeft">0px</property>
 <property name="paddingBottom">0px</property>
 <property name="paddingRight">0px</property>
 </style>
 </styles>
 <page-setup>
 <simple-master-page name="Simple MasterPage" id="2">
 <property name="type">a4</property>
 <property name="topMargin">4mm</property>
 <property name="leftMargin">4mm</property>
 <property name="bottomMargin">2mm</property>
 <property name="rightMargin">2mm</property>
 <property name="paddingTop">0pt</property>
 <property name="paddingLeft">0pt</property>
 <property name="paddingBottom">0pt</property>
 <property name="paddingRight">0pt</property>
 <property name="canShrink">true</property>
 <property name="showHeaderOnFirst">true</property>
 <property name="headerHeight">17mm</property>
 <property name="footerHeight">8mm</property>
 <page-header>
 <image name="logo111" id="258">
 <property name="marginLeft">15.2cm</property>
 <property name="height">1.3123333333333336cm</property>
 <property name="width">4.080933333333333cm</property>
 <structure name="toc"/>
 <property name="source">embed</property>
 <property name="imageName">my-w3.jpg</property>
 </image>
 </page-header>
 <page-footer>
 <text name="my-footer" id="105">
 <property name="textAlign">center</property>
 </text>
 </page-footer>
 </simple-master-page>
 </page-setup>
 <body>
 <grid name="New grid 0" id="139">
 <property name="marginTop">0mm</property>
 <list-property name="boundDataColumns">
 <structure>
 <property name="name">imgBarCode</property>
 <expression name="expression" type="javascript">reportContext.getAppContext().get("imgBarCode");</expression>
 <property name="dataType">blob</property>
 </structure>
 </list-property>
 <column id="140">
 <property name="width">1cm</property>
 <property name="paddingTop">0pt</property>
 <property name="paddingLeft">0pt</property>
 <property name="paddingBottom">0pt</property>
 <property name="paddingRight">0pt</property>
 </column>
 <column id="141">
 <property name="width">18cm</property>
 <property name="paddingTop">0pt</property>
 <property name="paddingLeft">0pt</property>
 <property name="paddingBottom">0pt</property>
 <property name="paddingRight">0pt</property>
 </column>
 <row id="142">
 <cell id="143">
 <property name="width">1cm</property>
 <image name="imgBarCode" id="148">
 <property name="marginTop">124mm</property>
 <property name="paddingTop">0pt</property>
 <property name="paddingLeft">0pt</property>
 <property name="paddingBottom">0pt</property>
 <property name="paddingRight">0pt</property>
 <property name="height">36mm</property>
 <property name="width">8mm</property>
 <property name="source">expr</property>
 <expression name="valueExpr">row["imgBarCode"]</expression>
 </image>
 </cell>
 <cell id="144">
 <property name="borderBottomStyle">none</property>
 <property name="paddingTop">0pt</property>
 <property name="paddingLeft">0pt</property>
 <property name="paddingBottom">0pt</property>
 <property name="paddingRight">0pt</property>
 </cell>
 </row>
 </grid>
 </body>
 <list-property name="images">
 <structure>
 <property name="name">my-w3.jpg</property>
 <property name="data">
 /9j/4AAQSkZJRgABAQEBLAEsAAD/4QDwRXhpZgAATU0AKgAAAAgACQExAAIAAAARAAAAegEyAAIAAAAU
 [snipped binary data]
 GpVnN8022/MKKKKzMwooooAKKKKACiiigD//2Q==
 </property>
 </structure>
 </list-property>
 </report> 

 
Any assistance would be greatly appreciated.
 Regards,
 Susana 


Reproducible: Sometimes

Steps to Reproduce:
1.A report template with and embedded logo
2.Reloading the logo before rendering to pdf
3.Lots of threads doing the same thing, each using it's own copy of both template and logo.
Comment 1 Susana Domingos CLA 2011-09-14 05:45:46 EDT
Solved.

It was due my mistake all the time; the error message simply didn't point in any direction.

The solution has one main-thread which spawns N children. It uses a queue to place each reposrts info and the children are the renderers.
My mistake was to have the main-thread create everything down to the run-time session and pass each child a reference to that session. Since no one ever closed anything regarding the session, it grew tremendously. Only when I was checking out memory consumption did I stumble upon this.

The fix was to pass a reference to the run-time engine and have each child open/close it's own session. Since then we have processed thousands of reports and this issue has never occurred again.