SAP Knowledge Base Article - Public

1459752 - Exporting using the CRJ only the first page is rendered

Symptom

  • When exporting using Crystal Reports for Java (CRJ), only the first page is exported.
  • This issue occurs when a heavy load is put on the CRJ application.

Environment

Crystal Reports for Eclipse 2.0

JDK 1.6.x

Cause

The issue has been identified and logged under Problem Report ID ADAPTXXXXXXXX.  The background of the issue is:

  • The problem is caused by a bug in Sun’s server JVM: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5091921
  • In the server JVM (and not in the client JVM), the HotSpot compiler may incorrectly flip the sign of Integer.MAX_VALUE in the loop optimizer for page exporting.  This means that the loop will work normally for a while, but when the HotSpot compiler decides to compile the loop (because the loop is “hot code”), it may incorrectly compile the loop conditions in such a way that the loop no longer works normally.  In our case, the loop was something like this: 
       for (pageNum = 1; pageNum <= endPageNum; pageNum++)
       {
              exportPage (pageNum);
       }
  • endPageNum was initialized to Integer.MAX_VALUE, which his the default end page number to use when the user does not specify an end page number. During normal execution, this works properly.  But during high load, the HotSpot compiler will compile this loop to incorrect code, resulting in the loop exiting after the first page.  When I hard-coded endPageNum to (Integer.MAX_VALUE – 1), then problem did not happen.

 

Resolution

  • The issue has been fixed in the latest version of Crystal Reports Java.  There are also two workarounds that will stop the issue from happening:
  • You can work around the problem by specifying an end page number for the export.  You can use any number that is larger than the number of pages in the report (for example: 1,000,000).  Here is the code example to prevent the problem:

final ExportOptions exportOptions = new ExportOptions ();

exportOptions.setExportFormatType (ReportExportFormat.PDF);

final PDFExportFormatOptions pdfOptions = new PDFExportFormatOptions ();

pdfOptions.setEndPageNumber (100000);

exportOptions.setFormatOptions (pdfOptions);

final ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) rcd.getPrintOutputController ().export (exportOptions);

  • The other possibility is to use the JVM client option instead of the server option.

Keywords

KBA , BI-DEV-JAV , BI Software Development Kits (SDKs) - Java , Problem

Product

Crystal Reports, version for Eclipse 2.0