[#2935] - Serious problem on JRPrintServiceExporter.exportReport() while network printer timed out or latency

Category:
Bug report
Priority:
Urgent
Status:
New
Project: Severity:
Critical
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:

Hello Friends,

We have wrapped JasperReports based printing Software as a Windows Service and This report printing software is running 24/7.

We are facing some intermittent network printer latency and timed out issue at our network and during this latency/timed out the JRPrintServiceExporter.exportReport() goes to hang state nothing is get printed, as soon as the network latency is back to normal we need to restart the window service always to print document.

Here is our printer exporting code.

public long directReportPrinting(JasperPrint jasperPrint, String printername, int copies) {
JRPrintServiceExporter exporter = null;
//setting ireturn value to always error
int ireturn = -1;

try {
exporter = new JRPrintServiceExporter();
lg.debug("Looking for printer service...");
PrintService[] services = PrintServiceLookup.lookupPrintServices(
null, null);
int selectedService = -1;
for (int i = 0; i < services.length; i++) {
if (services[i].getName().contains(printername)) {
selectedService = i;
}
}
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
MediaSizeName mediaSizeName = MediaSize.ISO.A4.getMediaSizeName();
printRequestAttributeSet.add(mediaSizeName);
printRequestAttributeSet.add(new Copies(copies));

exporter
.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(
JRPrintServiceExporterParameter.PRINT_SERVICE,
services[selectedService]);

exporter
.setParameter(
JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET,
services[selectedService].getAttributes());

exporter
.setParameter(
JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET,
printRequestAttributeSet);

exporter.setParameter(
JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,
Boolean.FALSE);

exporter.setParameter(
JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG,
Boolean.FALSE);
lg.info("Printing...");

exporter.exportReport();

lg.info("Document has been printed...");
ireturn = 0;
} catch (JRException e) {
// TODO Auto-generated catch block
lg.error("Error " + e.getMessage());
e.printStackTrace();
}

return ireturn;
}

Seems to be network latency is never handled/timed out at JRPrintServiceExporter class...!

Instead of exporting directly to the printer, Is it possible add a job to Windows spooler printer queue to handle (like Windows word or excel application printing) if this is supported then windows spooler will takes the control to print the document.

Above issue is terribly affecting our printing solutions so, Please give us your suggestion and recommendation.

Appreciate you in advance.

:(
Shekhar
:(

v5.1
shekhar's picture
Joined: Nov 15 2007 - 5:05pm
Last seen: 5 years 9 months ago
Feedback