We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

JRException when exporting report with page break

Hi everybody,


I’m opening this thread to report an error I am facing when trying to compile and save a report from a JasperReport template.

Here is the error I get:

net.sf.jasperreports.engine.JRException
at com.aspose.words.jasperreports.AWAbstractExporter.exportReport(Unknown Source)
at com.agews.suite626.servlet.old.Servlet.export(Servlet.java:198)
at com.agews.suite626.servlet.old.Servlet.compile(Servlet.java:744)
at com.agews.suite626.servlet.old.ReportRumore.compile(ReportRumore.java:146)
at com.agews.suite626.servlet.old.ReportRumore.process(ReportRumore.java:46)
at com.agews.suite626.servlet.old.Servlet.doPost(Servlet.java:161)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

The export method is the following:

protected byte[] export(JasperPrint jasperPrint, JRExporter exporter) throws JRException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
exporter.exportReport();
return baos.toByteArray();
}

where JRExporter exporter is actually an instance of AWDocExporter.

I have located the problem in the page break which is present in sub_report_1.jrxml of report 99_35, in fact if I remove it, all works as expected.

However, I do not understand why it would cause an error, in fact there are other page breaks in other reports, which works, and the PAGE_BREAKS export option is set to export them as normal.

I have attached a .zip archive containing both the report template and its .jrprint

Hi Matteo,


Thanks for your inquiry. There are thirteen sub reports for 99_35. Could you please share the data source of your jrxml file so that I can execute these reports in iReprots for investigation purposes.

Please also share your code for jrxml parameters which you need to execute jrxml files. I will investigate the issue on my side and provide you more information.

Moreover, I am able to export the 99_35.jrprint with AWDocExporter and have not found any exception.

The data comes from a MySQL database, I do not think I have any way of passing it to you.


Anyway, the issue should not be the data, but that specific page break, in fact if I remove it all works properly.

If you really need the actual data, please suggest how to provide it.

BTW: I am using Aspose.Words for JasperReports version 1.8.0 with JasperReports 5.1

Hi Matteo,


Thanks for sharing the details. I have executed again your .jrprint file with page break option as ‘Normal’ and faced the same exception.

exporter.setParameter(AWExporterParameter.PAGE_BREAKS, AWExporterParameter.PAGE_BREAKS_NORMAL);

I have logged this issue as WORDSJSP-113 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

However, It would be great if you please provide the CSV or XML data-source for your jrxml file which causes the page break issue. To investigate this issue, we need to export your jrxml file to Doc at our side.

tahir.manzoor:
However, It would be great if you please provide the CSV or XML data-source for your jrxml file which causes the page break issue. To investigate this issue, we need to export your jrxml file to Doc at our side.

I will try to provide you what you ask for, but I cannot assure that I'll be able to.

However, if you are able to reproduce the issue without my specific data, shouldn't this mean that the issue is not related to the data itself?

Hi Matteo,


Thanks for your inquiry. Yes, the problem should not be with data. Please note that MS Word document is flow document and does not contains any information about its layout into lines and pages. The exception is related to PAGE_BREAKS as normal. So, it may be possible our development team needs the data source to investigate this issue. I will let you know if we need the datasoruce.

Please let us know if you have any more queries.


The problem seems to be much bigger than I thought.


I am attaching another report which causes this same exception: this time the exception is thrown from sub_report_1.jrxml, specifically from the text field containing $F{misure_tecniche}.

However, if I remove the flag to extend if needed, this subreport compiles normally, and the exception is thrown by sub_report_3.jrxml, for reasons I haven’t found out yet.

What is more disturbing is that all this reports worked perfectly before, and I am unable to find out what went wrong…

After some further investigations, I have come to think that this issue might be related to the way your library, or JasperReport, tries to split a detail band in two pages when the content overflow.


I have in fact encountered a situation where the same report compiles correctly in one case and fails in another, just with a little change in the data.

To allow you to test our templates using our own data, I’ve created an online sandbox of our web application, and I am attaching an excel sheet with both the connection parameters and the significant report parameters values.

This should allow you to test our templates directly against our own data source.

I would like to underline that this issue is quite critical for us, in fact it could make our software very unstable, with obvious problems with our customers should the reporting engine start failing randomly.

Hi again,


I am attaching another example, this time it is a template like I said before, which seems to fail depending on its data.

The .zip archive contains
- the .jrxml template files
- a .jrprint for which the template compiles correctly
- a .jrprint for which the template fails to compile and throws the exception

Hope this helps.

Hi Matteo,


Thanks for your inquiry.
mtassinari:
To allow you to test our templates using our own data, I’ve created an online sandbox of our web application, and I am attaching an excel sheet with both the connection parameters and the significant report parameters values.
I am unable to access your web site for datasrouce. Please check the information of your Excel sheet. I am getting following error.

ERROR: Incorrect Login! Please try again …

I have managed to reproduce the same exception with mod_3.zip files. However, I am unable to reproduce exception issue with failure.jrprint.

The login credentials are correct, I am able to obtain a valid connection using the attached piece of code.


I also tested it through plain command line with a mysql client, and that works too.

What do you mean with this: However, I am unable to reproduce exception issue with failure.jrprint. ?

Hi Matteo,


Thanks for your inquiry.
mtassinari:
What do you mean with this: However, I am unable to reproduce exception issue with failure.jrprint. ?
I can export the failure.jrprint at my side by using Aspose.Words for JasperReports. I have attached the output Doc file with this post for your kind reference.

AWDocExporter exporter = new
AWDocExporter();<o:p></o:p>

exporter.setParameter(AWExporterParameter.PAGE_BREAKS, AWExporterParameter.PAGE_BREAKS_NORMAL);

exporter.setParameter(JRExporterParameter.INPUT_FILE_NAME, "C:\\failure.jrprint");

exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "C:\\Out.doc");

exporter.exportReport();

mtassinari:
The login credentials are correct, I am able to obtain a valid connection using the attached piece of code.
Currently, I am facing mysql jdbc driver issue. I will fix this issue and will let you know. Could you please share the sample code snippet with your MYSQL Connection to fill your jrxml reports?

tahir.manzoor:
Could you please share the sample code snippet with your MYSQL Connection to fill your jrxml reports?

The code of our servlets, which perform the reporting compile and fill, is quite complex and probably it would not be of help for you, being hundreds of lines of code.

Anyway, here are some more parameters we are currently using:

exporterDOC.setParameter(AWExporterParameter.EXPORT_LINES, true));
exporterDOC.setParameter(AWExporterParameter.PAGE_BREAKS, 0));
exporterDOC.setParameter(AWExporterParameter.PAGE_MARGINS, "60px;60px;50px;10px");
exporterDOC.setParameter(AWExporterParameter.RECOGNIZE_FIELDS, true));
exporterDOC.setParameter(AWExporterParameter.SPACING_FACTOR, 1.0));

Hope this helps.

Any hint for a possible ETA for the solution of this issue?


It has become quite serious for us, since now all of our JasperReport-based template can randomly fail on the sole base of their content…

I am attaching another example of a template which compiles correctly on one occasion and fails on another.


I hope this time you’ll be able to reproduce the issue with the failure.jrprint file.

I think I have been able to isolate the problem once and for all.


If, from our servlet which compiles the templates, I remove the line

exporterDOC.setParameter(AWExporterParameter.PAGE_BREAKS, 0);

then the same template I attached before, which compiled successfully in one case and failed in another, now compiles successfully in both cases.

I am attaching the new .jrprint obtained by removing the export parameter, see if you can obtain something useful by comparing it with my previously attached failure.jrprint

However, I fear that removing that option is not feasible for us, because we have many templates in which we placed page breaks where we needed them, and if they are no longer exported, the document’s layout would be broken.

Also, as I said in a previous post, this used to work before we switched to latest version of Aspose.Words for JasperReport 1.8.0 and JasperReport 5.1



EDIT:

What is the default value for AWExporterParameter.PAGE_BREAKS if not explicitly set? If I simply remove the line, I get a document which is 73 pages long, while if I set it to AWExporterParameter.PAGE_BREAKS_NONE I get a document which is only 45 pages long, so I must assume that this last value is not the default.

From what I remember, I thought the default value was AWExporterParameter.PAGE_BREAKS_NORMAL but, if so, why would if fail when I set it explicitly to the default value?

OT: why are all my posts marked as “private” and I cannot untick the option?



EDIT 2:

According to http://www.aspose.com/docs/display/wordsjasperreports/Page+Breaks it would seem that the default value is AWExporterParameter.PAGE_BREAKS_SECTIONS, and this is why we had that line in our servlet, 'cause we need normal page breaks and not section breaks, however the exporting of normal page breaks seems broken.
Hi Matteo,

Thanks for your inquiry.
mtassinari:
Any hint for a possible ETA for the solution of this issue?
Currently, your issue is pending for analysis and is in the queue. I am afraid, I cannot provide you any reliable estimate at the moment. Once your issue is analyzed, we will then be able to provide you an estimate.
mtassinari:
If, from our servlet which compiles the templates, I remove the line

exporterDOC.setParameter(AWExporterParameter.PAGE_BREAKS, 0);
When you use AWExporterParameter.PAGE_BREAKS_NORMAL to export Doc file, it throws exception and this issue logged as WORDSJSP-113.
mtassinari:
Also, as I said in a previous post, this used to work before we switched to latest version of Aspose.Words for JasperReport 1.8.0 and JasperReport 5.1
Please share the Jasper Report version and Aspose.Words for JasperReport version for which your jrxml works. Could you please share the .jrprint file which works in old version?
mtassinari:
OT: why are all my posts marked as "private" and I cannot untick the option?
While creating new post, you selected the option 'Keep this post private'. Please do not select this option if you want to make your thread as public.

Moreover, the default value for page braek is AWExporterParameter.PAGE_BREAKS_SECTIONS.

tahir.manzoor:
When you use AWExporterParameter.PAGE_BREAKS_NORMAL to export Doc file, it throws exception and this issue logged as WORDSJSP-113.

What I wanted to say is that initially I thought it was a problem with the data, and then I found what was actually causing it, allowing us to solve the problem for now. However, we would need the "normal page break" functionality working.

tahir.manzoor:
Please share the Jasper Report version and Aspose.Words for JasperReport version for which your jrxml works. Could you please share the .jrprint file which works in old version?

We were using Aspose.Words for JasperReport version 1.3.1 and JasperReport 4.5.1, but I am afraid I can no longer create a .jrprint for you, it would take too long for me to take the infrastructure back as it was.

tahir.manzoor:
While creating new post, you selected the option 'Keep this post private'. Please do not select this option if you want to make your thread as public.

My mistake then, but I wouldn't mind if you could put it back to public.
Hi Matteo,

Thanks for sharing the detail.
mtassinari:
What I wanted to say is that initially I thought it was a problem with the data, and then I found what was actually causing it, allowing us to solve the problem for now. However, we would need the "normal page break" functionality working.
It is nice to hear from you that you have found the problem and can solve it. However, we will update you via this forum thread once this issue is resolved.

Moreover, I have made this forum thread as public. Please let us know if you have any more queries.