JDK-6520121 : Cant' print: /usr/bin/lpr seems to be hardcoded in PSPrinterJob
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2007-02-01
  • Updated: 2024-06-11
  • Resolved: 2007-02-01
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Ubuntu Linux 5.10

EXTRA RELEVANT SYSTEM CONFIGURATION :
Using a remote CUPS server. The CUPS_SERVER variable is set to point to it.

A DESCRIPTION OF THE PROBLEM :
I can't print using a remote CUPS server. It seems Java fails to communicate using IPP, so it tries to fallback to "lpr" command. However, the path is hardcoded to "usr/bin/lpr", but in my system it's located in "usr/local/bin/lpr".


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to print using a remote CUPS server, in a system where lpr is installed under /usr/local/bin. You always get this error.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The job should be sent to the printer.
ACTUAL -
An exception.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
javax.print.PrintException: java.awt.print.PrinterIOException
        at sun.print.UnixPrintJob.printableJob(UnixPrintJob.java:623)
        at sun.print.UnixPrintJob.print(UnixPrintJob.java:475)
        at com.iver.cit.gvsig.gui.layout.Layout.showPrintDialog(Layout.java:981)
        at com.iver.cit.gvsig.Print$1.run(Print.java:132)
        at com.iver.andami.PluginServices$1.run(PluginServices.java:454)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at com.iver.andami.ui.AndamiEventQueue.dispatchEvent(AndamiEventQueue.java:58)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.awt.print.PrinterIOException
        at sun.print.PSPrinterJob$PrinterSpooler.run(PSPrinterJob.java:650)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.print.PSPrinterJob.endDoc(PSPrinterJob.java:696)
        at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1443)
        at sun.print.UnixPrintJob.printableJob(UnixPrintJob.java:618)
        ... 13 more
Caused by: java.io.IOException: Cannot run program "/usr/bin/lpr": java.io.IOException: error=2, No such file or directory
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
        at java.lang.Runtime.exec(Runtime.java:593)
        at java.lang.Runtime.exec(Runtime.java:466)
        at sun.print.PSPrinterJob$PrinterSpooler.run(PSPrinterJob.java:645)
        ... 17 more
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
        at java.lang.ProcessImpl.start(ProcessImpl.java:65)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
        ... 20 more


REPRODUCIBILITY :
This bug can be reproduced always.

Comments
EVALUATION Note that I think the real problem here is: > It seems Java fails to communicate using IPP For most things we communicate directly with CUPS but for sending the actual print data we still use lpr, and should instead spool the data directly to CUPS. If that was working properly, then finding lpr would not be an issue, since as mentioned in 4988591, it was closed as will not fix in part because when moving towards CUPS as an API instead of execing lpr. This is to be addressed as : 6520478: Use HTTP instead of lpr for sending print data in CUPS
06-02-2007