Export to Text givesArrayIndexOutOfBoundsException

I have huge data for this report. It fails with a below exception. Does anybody has a resolution to this problem or any idea why this exception occurs while exporting report in text format.

java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at net.sf.jasperreports.engine.export.JRTextExporter.exportText(JRTextExporter.java:476)
at net.sf.jasperreports.engine.export.JRTextExporter.exportElements(JRTextExporter.java:345)
at net.sf.jasperreports.engine.export.JRTextExporter.exportPage(JRTextExporter.java:322)
at net.sf.jasperreports.engine.export.JRTextExporter.exportReportToWriter(JRTextExporter.java:298)
at net.sf.jasperreports.engine.export.JRTextExporter.exportReport(JRTextExporter.java:240)
at com.db.longarch.steps.CreateJasperReportSteps.callJasperReport(CreateJasperReportSteps.java:132)
at com.db.longarch.steps.CreateJasperReportSteps.step(CreateJasperReportSteps.java:78)
at com.db.servicemanagement.TransactionDispatchService.startDispatch(TransactionDispatchService.java:303)
at com.db.servicemanagement.TransactionDispatchService.run(TransactionDispatchService.java:103)
at com.db.servicemanagement.ServiceThread.run(ServiceThread.java:68)
at java.lang.Thread.run(Thread.java:595)

Regards,

Gary
Post edited by: gshahri, at: 2008/06/05 16:18

gshahri's picture
171
Joined: Jun 5 2008 - 2:06am
Last seen: 14 years 12 months ago

15 Answers:

What JR version are you using? Does this happen with JR >= 2.0.1?

Regards,
Lucian

lucianc's picture
76110
Joined: Jul 17 2006 - 1:10am
Last seen: 19 hours 31 min ago
Thanks for reply.

Initially I was using JasperReports-2.0.0.jar. But then using similar input, I switched to
JasperReports-2.0.4.jar.

But still problem persists.

I will be grateful I you can help me here.

Thanks,

Girish S.
gshahri's picture
171
Joined: Jun 5 2008 - 2:06am
Last seen: 14 years 12 months ago
Unless you post a sample that can be used to reproduce this, I'm afraid I can't guess what the cause is.

Also, could you post the exception stack trace that you get with JR 2.0.4?

Regards,
Lucian
lucianc's picture
76110
Joined: Jul 17 2006 - 1:10am
Last seen: 19 hours 31 min ago

Here is what all u need to further investigate the problem.

To briefly describe the scenario that is causing problem.
a. It has a subreport within a master report.
b. Subreport exception class is InputStream as a parameter
c. I am attaching the document pointing the jar being used and reportDesign.
d. Is is something to do with Parameter setting before export ? Currently, we are just setting these
exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE, destFile);
exporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH,new Integer(10));
exporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT,new Integer(10));

e. Below is the stacktrace of exception with 2.0.4

2008-06-06 13:29:04,799 ERROR [com.db.longarch.steps.CreateJasperReportSteps] - Error in callJasperReport() while creating report for generatedReports/AXSPoint/EXCEPTIONREPORT.rpt
java.lang.ArrayIndexOutOfBoundsException: -9107
at net.sf.jasperreports.engine.export.JRTextExporter.exportText(JRTextExporter.java:475)
at net.sf.jasperreports.engine.export.JRTextExporter.exportElements(JRTextExporter.java:339)
at net.sf.jasperreports.engine.export.JRTextExporter.exportPage(JRTextExporter.java:316)
at net.sf.jasperreports.engine.export.JRTextExporter.exportReportToWriter(JRTextExporter.java:292)
at net.sf.jasperreports.engine.export.JRTextExporter.exportReport(JRTextExporter.java:234)
at com.db.longarch.steps.CreateJasperReportSteps.callJasperReport(CreateJasperReportSteps.java:132)
at com.db.longarch.steps.CreateJasperReportSteps.step(CreateJasperReportSteps.java:78)
at com.db.servicemanagement.TransactionDispatchService.startDispatch(TransactionDispatchService.java:303)
at com.db.servicemanagement.TransactionDispatchService.run(TransactionDispatchService.java:103)
at com.db.servicemanagement.ServiceThread.run(ServiceThread.java:68)
at java.lang.Thread.run(Thread.java:595)

regards,

Girish. [file name=JasperReportException.doc size=199680]
Post edited by: gshahri, at: 2008/06/06 17:46

gshahri's picture
171
Joined: Jun 5 2008 - 2:06am
Last seen: 14 years 12 months ago
A screenshot of the the report design will not help us reproduce the problem. Could you post the master and subreport JRXML, plus an XML export of the report that causes the text exporter failure?

Regards,
Lucian
lucianc's picture
76110
Joined: Jul 17 2006 - 1:10am
Last seen: 19 hours 31 min ago

Attached are the jrxml files as required by you. I am using Java program to export to text. I am calling callJasperReports method which actually invokes the exportReport()

Regards,

Girish [file name=jrxmls-aa5875a0160ecb5726c58573b7c16626.zip size=5949]

gshahri's picture
171
Joined: Jun 5 2008 - 2:06am
Last seen: 14 years 12 months ago
lucianc wrote:
plus an XML export of the report that causes the text exporter failure?


Any chance of seeing the XML export?

Regards,
Lucian
lucianc's picture
76110
Joined: Jul 17 2006 - 1:10am
Last seen: 19 hours 31 min ago
Hi Lucian

Sorry I did not understand your last reply. Do u want me to change something in the code ?

Can you please elaborate more on this. I don't have any XML apart from jrxmls that I have already sent.

My objective is to generate the report in Text Format. But currently , It generates 0 byte file after throwing following exception

java.lang.ArrayIndexOutOfBoundsException: -9107
at net.sf.jasperreports.engine.export.JRTextExporter.exportText(JRTextExporter.java:475)
at net.sf.jasperreports.engine.export.JRTextExporter.exportElements(JRTextExporter.java:339)
at net.sf.jasperreports.engine.export.JRTextExporter.exportPage(JRTextExporter.java:316)
at net.sf.jasperreports.engine.export.JRTextExporter.exportReportToWriter(JRTextExporter.java:292)
at net.sf.jasperreports.engine.export.JRTextExporter.exportReport(JRTextExporter.java:234)
at com.db.longarch.steps.CreateJasperReportSteps.callJasperReport(CreateJasperReportSteps.java:132)
at com.db.longarch.steps.CreateJasperReportSteps.step(CreateJasperReportSteps.java:78)
at com.db.servicemanagement.TransactionDispatchService.startDispatch(TransactionDispatchService.java:303)
at com.db.servicemanagement.TransactionDispatchService.run(TransactionDispatchService.java:103)
at com.db.servicemanagement.ServiceThread.run(ServiceThread.java:68)
at java.lang.Thread.run(Thread.java:595)


Regards,

Girish.
Post edited by: gshahri, at: 2008/06/10 15:23
gshahri's picture
171
Joined: Jun 5 2008 - 2:06am
Last seen: 14 years 12 months ago
gshahri wrote:

Sorry I did not understand your last reply. Do u want me to change something in the code ?


I was asking whether you could export the JasperPrint object (that fails when exported to text) to XML (using [url=http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/exp...) and post the XML export file here.

I tried replicating your issue by feeding some dummy data to the JRXMLs you posted, but the text export worked fine. Since I do not have access to the data you use to fill the reports, the only way to reproduce the problem is to get a filled report (as an XML export) from you.

Regards,
Lucian
lucianc's picture
76110
Joined: Jul 17 2006 - 1:10am
Last seen: 19 hours 31 min ago

Hi Lucian,

Thanks for explaining. I managed to export the report as XML using JRXmlExporter. Please find the generated xml report file.

Regards,

Girish S. [file name=exception.zip size=162117]

gshahri's picture
171
Joined: Jun 5 2008 - 2:06am
Last seen: 14 years 12 months ago
Thank you, we managed to replicate the error.

Could you please post this as a bug [url=http://jasperforge.org/sf/tracker/do/listArtifacts/projects.jasperreport..., so that we can properly track it?

Regards,
Lucian
lucianc's picture
76110
Joined: Jul 17 2006 - 1:10am
Last seen: 19 hours 31 min ago
Hi Lucian,

Thanks for the prompt response. I will certainly report this as a bug. But I would appreciate if you can reply to following queries

a. How long it may take to get a fix for this bug ? so that I can plan accordingly.

b. Can you suggest any work-around for resolving this problem ? Such as using other versions (latest) of the JasperReports or some Tweaking in the java code

c. It would be helpful, if you provide more insight into this bug. Is this a data issue? or Is this pertaining to particular sequence of characters ? or any other setting/parameter or something else

Thanks again for your cooperation

Regards,

Girish S.
gshahri's picture
171
Joined: Jun 5 2008 - 2:06am
Last seen: 14 years 12 months ago

gshahri wrote:

a. How long it may take to get a fix for this bug ? so that I can plan accordingly.

We've already analyzed the bug, and a fix for it will be checked-in very shortly on the JasperReports SVN trunk.

b. Can you suggest any work-around for resolving this problem ? Such as using other versions (latest) of the JasperReports or some Tweaking in the java code

You can workaround the bug by extending JRTextExporter and overriding a method (and using this extended exporter in your code):

Code:
//extend the JR text exporter
public class PatchedTextExporeter extends JRTextExporter {
  	//overriding to fix the bug
  	protected int calculateYCoord(int y) {
		return (int) (((long) pageHeight * y) / jasperPrint.getPageHeight());
	}
}
Ā 
//then use the extended exporter:
JRTextExporter exporter = new PatchedTextExporeter();
...
c. It would be helpful, if you provide more insight into this bug. Is this a data issue? or Is this pertaining to particular sequence of characters ? or any other setting/parameter or something else

The bug occurs when reports containing very tall pages are exported to text. Such reports are usually produced by filling a report with pagination ignored (which I assume is what you did).

Regards,
Lucian

lucianc's picture
76110
Joined: Jul 17 2006 - 1:10am
Last seen: 19 hours 31 min ago
Hi Lucian,

I downloaded the fix for artf3271, but I was not able to compile that. It fails at line 104

filter = createFilter(TXT_EXPORTER_PROPERTIES_PREFIX);

This method doesn't exists.

I hope this patch was applied on JasperReports2.0.4

Regards,

Girish S.
gshahri's picture
171
Joined: Jun 5 2008 - 2:06am
Last seen: 14 years 12 months ago
The fix was applied to the JasperReports SVN trunk, and not to JR 2.0.4. Getting the JRTextExporter.java file from the SVN trunk and trying to use it in JR 2.0.4 would not work due to other code changes that occurred after the 2.0.4 release.

If you want to fix the issue in 2.0.4, either extend the 2.0.4 JRTextExporter as I've explained below, or get the 2.0.4 sources and apply the fix to the 2.0.4 JRTextExporter.java.

Regards,
Lucian
lucianc's picture
76110
Joined: Jul 17 2006 - 1:10am
Last seen: 19 hours 31 min ago
Feedback
randomness