-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8u162
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Current Windows 10, JDK 1.8.0_162, might be 32 or 64bit, forgot to ask.
A DESCRIPTION OF THE PROBLEM :
It is BugJDK-8039412, but it still occures in 1.8.0_162, so the fixed message for 8u161 cannot be correct.
I work around this by setting the printer like this:
// Fix for #113140 - java.lang.StackOverflowError - Should be fixed in Java 9
// See https://bugs.openjdk.java.net/browse/JDK-8133737
if( printerJob.getPrintService() == null ) {
try {
printerJob.setPrintService(PrintServiceLookup.lookupDefaultPrintService());
} catch( PrinterException e ) {
// Okay, stuff gets persistent here. We just try to set ANY PrintService here.
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
for( PrintService printService : printServices ) {
try {
printerJob.setPrintService(printService);
break;
} catch( PrinterException e2 ) {
}
};
}
}
if( printerJob.getPrintService() == null ) {
// Still no print service in printJob. This will lead to an exception later when we want to display
// the print dialog so we can just throw the towel here.
throw new UserException("Keine brauchbaren Drucker auf Ihrem System gefunden.");
}
The reason why printerJob.setPrintService(PrintServiceLookup.lookupDefaultPrintService()); did not work was because the system complains about an "invalid printer name". The default printer was the "Send to OneNote 2010" printer, also after I switched the default printer on my customers system. Anyway, I just slap another printer onto the printjob until it does not complain anymore and now I can print again at my customer.
I have the slight feeling that something like my code should be in the JDK itself, where the printerjob is created, but I don't know about the side effects.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Have a system where PrintServiceLookup.lookupDefaultPrintService() returne the "Send to OneNote 2010" printer. Don't know how to set this up.
Try to to create a PrinterJob:
PrinterJob printerJob = PrinterJob.getPrinterJob();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
printerJob.getPrintService() != null
ACTUAL -
printerJob.getPrintService() == null
CUSTOMER SUBMITTED WORKAROUND :
See description.
FREQUENCY : rarely
Current Windows 10, JDK 1.8.0_162, might be 32 or 64bit, forgot to ask.
A DESCRIPTION OF THE PROBLEM :
It is Bug
I work around this by setting the printer like this:
// Fix for #113140 - java.lang.StackOverflowError - Should be fixed in Java 9
// See https://bugs.openjdk.java.net/browse/JDK-8133737
if( printerJob.getPrintService() == null ) {
try {
printerJob.setPrintService(PrintServiceLookup.lookupDefaultPrintService());
} catch( PrinterException e ) {
// Okay, stuff gets persistent here. We just try to set ANY PrintService here.
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
for( PrintService printService : printServices ) {
try {
printerJob.setPrintService(printService);
break;
} catch( PrinterException e2 ) {
}
};
}
}
if( printerJob.getPrintService() == null ) {
// Still no print service in printJob. This will lead to an exception later when we want to display
// the print dialog so we can just throw the towel here.
throw new UserException("Keine brauchbaren Drucker auf Ihrem System gefunden.");
}
The reason why printerJob.setPrintService(PrintServiceLookup.lookupDefaultPrintService()); did not work was because the system complains about an "invalid printer name". The default printer was the "Send to OneNote 2010" printer, also after I switched the default printer on my customers system. Anyway, I just slap another printer onto the printjob until it does not complain anymore and now I can print again at my customer.
I have the slight feeling that something like my code should be in the JDK itself, where the printerjob is created, but I don't know about the side effects.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Have a system where PrintServiceLookup.lookupDefaultPrintService() returne the "Send to OneNote 2010" printer. Don't know how to set this up.
Try to to create a PrinterJob:
PrinterJob printerJob = PrinterJob.getPrinterJob();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
printerJob.getPrintService() != null
ACTUAL -
printerJob.getPrintService() == null
CUSTOMER SUBMITTED WORKAROUND :
See description.
FREQUENCY : rarely