JDK-8046007 : Java app receives javax.print.PrintException: Printer is not accepting job.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u75,7u51,8u5,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-06-05
  • Updated: 2017-02-07
  • Resolved: 2014-08-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 JDK 8 JDK 9
6u91Fixed 7u80Fixed 8u40Fixed 9 b30Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
On Windows, a Java application is no longer able to send printing jobs into Windows printer spooler, if the related printer becomes unavailable for some reason. At this point, the Windows printer queue shows an error state ('Error - Printing').

If the Java application tries to print when Windows printer is in an error state, the Java print dialog shows 'Status: Not accepting jobs'. After pushing the print button, the app will fail printing with exception:

java.awt.print.PrinterException: Printer is not accepting job.
        at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1326)
        at javax.swing.text.JTextComponent$2.call(JTextComponent.java:2320)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at javax.swing.text.AbstractDocument.render(AbstractDocument.java:420)
        at javax.swing.text.JTextComponent$3.run(JTextComponent.java:2369)
        at java.lang.Thread.run(Thread.java:744)

At the same time, regular Windows applications (e.g Word) can still add new print jobs to the queue of this printer.
Comments
Root cause: Win32PrintService.getPrinterIsAcceptingJobs calls getJobStatus(printer, 2) and if it returns anything but 1, the status is PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS. getJobStatus method is native, src/windows/native/sun/windows/WPrinterJob.cpp, it requests the current status of the associated printer and checks it for error conditions. There are seven conditions at the moment: - PRINTER_STATUS_ERROR - PRINTER_STATUS_NOT_AVAILABLE - PRINTER_STATUS_NO_TONER - PRINTER_STATUS_OUT_OF_MEMORY - PRINTER_STATUS_OFFLINE - PRINTER_STATUS_USER_INTERVENTION - PRINTER_STATUS_DOOR_OPEN At this state, printer is in an error condition and requires an action from the user to correctly process the queued print jobs. At the same Windows print manager accepts new print jobs. The proposed fix: Remove all the error states from the check and leave only one: PRINTER_STATUS_PENDING_DELETION. This state means "The printer is being deleted." Surely one cannot print to a deleted printer. See description of PRINTER_INFO_2 structure http://msdn.microsoft.com/en-us/library/windows/desktop/dd162845%28v=vs.85%29.aspx, its Status member, for complete list of possible error states. All other error states do not prevent a new print job to be added to the print queue. This fact is confirmed by Microsoft Knowledge Base article http://support.microsoft.com/kb/160129: ���A system Printer reports no status when the Printer queue is empty. In this state, the Printer is assumed ready to accept print jobs. This is a valid assumption even if the physical printer is in an error state such as off-line. The operating system considers the Printer ready to accept print jobs even if, for some reason, it cannot complete delivery to the physical printer. Such a circumstance is considered an error state in the operating system that must be addressed by the user. It is not considered an error reportable to the application that is allowed to complete the spooling of the print job successfully.��� In short: the Printer is assumed ready to accept print jobs ��� even if the physical printer is in an error state such as off-line. Some error states were already removed from the list of states which result in "Not accepting jobs", for example see JDK-6525150 which removed four paper-related error states: PRINTER_STATUS_PAPER_JAM, PRINTER_STATUS_PAPER_OUT, PRINTER_STATUS_PAPER_PROBLEM, PRINTER_STATUS_OUTPUT_BIN_FULL.
16-07-2014

Steps to reproduce: 1. Start TextPrintTest application. 2. Click Print button. It will show you Print dialog. 3. Select a print and click Print to check it prints successfully. 4. Make the printer go to an error condition. The easiest way to do it is to disconnect network cable from your laptop/desktop if you have a network printer or to power off your printer if it's local. 5. To update the status of the printer, you may need to send several more print jobs. 6. When Windows print queue shows an error near a document, click Print button in TextPrintTest again. You will see the status changed from "Accepting jobs" to "Not accepting jobs". If you click Print in the Print dialog, printing will fail with PrinterException from the description. Thus Java apps can't post print jobs to the queue any more whereas native Windows applications can do it successfully.
16-07-2014