Skip to Content
0
Former Member
Feb 02, 2012 at 08:47 PM

StringIndexOutOfBoundsException-Export Supervisor (page no. = 1 & horz page

56 Views

Sorry. I'm struggling with layout problem of my previous question. I hope this one will be better.

We are using the following crystalreport runtime. But we got Export Supervisor (page no. = 1 & horz page 0)

java.lang.StringIndexOutOfBoundsException about one per month roughly so far in production. Once it failed, the subsequent request from different users for getting crystal report would fail too. It seems like the crystal report engine couldn't recover from the first failure. Once fails, it always fails. We have to recycle the weblogic server to bring the application and crystal report back up again. Obviously, this is not a good thing in production. The good thing is that we have two servers in production. When this issue happens on one server, the other server continues to work for the application and crystal report. So this issue is not affecting the working server.

Can some expert here explain what does (page no. = 1 & horz page 0) mean? I have also attached the code snippet we have with has startPageNum, endPageNum in there. Could these two page nums create the problem? And any advise on

1. how to prevent the crystal report engine to recover from the first failure, meaning even if fails for the first request, the subsequent request from different users should continue to work.

2. how to fix the issue from the first place.

Thanks and any insights are greatly appreciated!

Eric

Manifes file

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.7.0

Created-By: 1.5.0_12-b04 (Sun Microsystems Inc.)

Product-Name: Crystal Reports Runtime Components

Implementation-Title: Crystal Reports Runtime Components

Implementation-Version: 12.2.200.454

Implementation-Vendor: Business Objects, Inc.(C)

The code snippet:

public byte[] getCrystalReportByType(URL reportURL, Map<String, Object> paramMap, CRExportType exportType,

int startPageNum, int endPageNum) throws Exception {

InputStream is = null;

ReportClientDocument clientDoc = null;

byte[] doc;

try {

URI uri = reportURL.toURI();

clientDoc= ReportClientDocument.openReport(new File(uri));

Set<Map.Entry<String, Object>> entrySet = paramMap.entrySet();

for (Map.Entry<String, Object> entry : entrySet) {

String param = entry.getKey();

CrystalReportServiceHelper.addDiscreteParameterValue(clientDoc, "", param, entry.getValue());

sLogService.debug("Setting parameters " + param + ": " + entry.getValue());

}

PageBasedExportFormatOptions formatOptions;

switch (exportType) {

case RTF:

formatOptions = new RTFWordExportFormatOptions();

break;

case WORD:

formatOptions = new RTFWordExportFormatOptions();

break;

case EXCEL:

formatOptions = new ExcelExportFormatOptions();

break;

default:

formatOptions = new PDFExportFormatOptions();

}

if (startPageNum > 0 && endPageNum > 0) {

formatOptions.setStartPageNumber(startPageNum);

formatOptions.setEndPageNumber(endPageNum);

}

ExportOptions exportOptions = new ExportOptions();

exportOptions.setExportFormatType(ReportExportFormat.from_int(exportType.getId()));

exportOptions.setFormatOptions(formatOptions);

is = new BufferedInputStream(clientDoc.getPrintOutputController().export(exportOptions));

ByteArrayOutputStream byteOs = new ByteArrayOutputStream();

byte[] data = new byte[1024];

while (is.read(data) > -1) {

byteOs.write(data);

}

doc = byteOs.toByteArray();

} catch (Exception e) {

sLogService.error("Error getting crystal report: " , e);

throw e;

} finally {

if (clientDoc != null)

clientDoc.close();

if (is != null)

is.close();

}

return doc;

Eric