JDK-6500903 : PrintServices are incorrectly listed as "not accepting jobs"
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2006-12-05
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
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.
Other JDK 6 JDK 7
5.0u12Fixed 6u1Fixed 7 b08Fixed
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b01)
Java HotSpot(TM) Client VM (build 1.5.0_09-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Linux epsilon 2.6.18 #2 SMP Wed Sep 27 16:45:04 CEST 2006 i686 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
CUPS installed: Common UNIX Printing System 1.2.4 (with bsd compat. binaries)

Environment Settings:
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="1" [2]="17" [3]="1" [4]="release" [5]="i486-pc-linux-gnu")
BASH_VERSION='3.1.17(1)-release'
COLORTERM=
COLUMNS=111
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-cuT1aAgzBG,guid=1d355445836615d62e0195668bac8400
DESKTOP_SESSION=default
DIRSTACK=()
DISPLAY=:0
DM_CONTROL=/var/run/xdmctl
EUID=1000
GROUPS=()
GS_LIB=/home/nikolai/.fonts
GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/nikolai/.gtkrc-2.0:/home/nikolai/.kde/share/config/gtkrc-2.0
GTK_RC_FILES=/etc/gtk/gtkrc:/home/nikolai/.gtkrc:/home/nikolai/.kde/share/config/gtkrc
HISTFILE=/home/nikolai/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/home/nikolai
HOSTNAME=epsilon
HOSTTYPE=i486
IFS=$' \t\n'
KDE_FULL_SESSION=true
KDE_MULTIHEAD=false
KONSOLE_DCOP='DCOPRef(konsole-3210,konsole)'
KONSOLE_DCOP_SESSION='DCOPRef(konsole-3210,session-2)'
LANG=de_DE@euro
LANGUAGE=de_DE:de:en_GB:en
LINES=58
LOGNAME=nikolai
MACHTYPE=i486-pc-linux-gnu
MAILCHECK=60
OLDPWD=/home/nikolai
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/home/nikolai/eclipse/plugins/org.apache.ant_1.6.5/bin
PIPESTATUS=([0]="0")
PPID=3210
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS2='> '
PS4='+ '
PWD=/home/nikolai/workspace/PrintTest
SESSION_MANAGER=local/epsilon:/tmp/.ICE-unix/3189
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=2
SSH_AGENT_PID=3144
SSH_AUTH_SOCK=/tmp/ssh-MFpYhy3111/agent.3111
TERM=xterm
UID=1000
USER=nikolai
WINDOWID=29360133
XCURSOR_THEME=default
XDM_MANAGED=/var/run/xdmctl/xdmctl-:0,maysd,mayfn,sched,rsvd,method=classic
_=-version


A DESCRIPTION OF THE PROBLEM :
There were some reports of PrintServices being incorrectly listed as "not accepting jobs" with recent versions of CUPS (e.g. in the comments of bug #6181488).

I was experiencing this as well and can confirm the following: it does no longer occur when the Java VM ist started with LANG=C.

Since the output of lpc status is localized according to the LANG setting supports the suggestion that this is indeed a parsing problem as suggested in the discussion.

With LANG=de_DE, my version of lpc status reads something like:
cos1:
        Drucker verbunden ��ber 'ipp' Geschwindigkeit -1
        Warteschlange ist freigegeben
        Drucken ist freigegeben
        Keine Eintr��ge
        Dienst l��uft

With LANG=C, it reads:
cos1:
        printer is on device 'ipp' speed -1
        queuing is enabled
        printing is enabled
        no entries
        daemon present


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
With CUPS 1.2.4 installed, compile the test program below and run

LANG=de_DE java PrintTest
LANG=C java PrintTest

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It is expected that the test program returns the same result when run with LANG=de_DE and with LANG=C
ACTUAL -
$ LANG=de_DE java PrintTest
Name: cos1 not-accepting-jobs
Name: cos2 not-accepting-jobs
...
$ LANG=C java PrintTest
Name: cos1 accepting-jobs
Name: cos2 accepting-jobs
...

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.standard.PrinterIsAcceptingJobs;


public class PrintTest {

	public static void main(String[] args) throws Exception{

	    PrintTest test = new PrintTest();
		test.list();
	}

	private void list() {
		PrintService[] services =
			PrintServiceLookup.lookupPrintServices(null, null);
		
		PrintService s = null;
		for (PrintService service : services) {
			System.out.println("Name: "+service.getName() + " " +
				service.getAttributes().get(PrinterIsAcceptingJobs.class));
		}

	}
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Setting LANG=C, although this it not feasable in our case, since all Java ressources are not localized anymore as well.

Comments
WORK AROUND 1. Set env CUPS_SERVER to localhost. 2. If /usr/lib/libcups.so is missing, create sym link /usr/lib/libcups.so -> /usr/lib/libcups.so.2
05-12-2006

EVALUATION Actually same as 6491871 but fix to that bug is incomplete. It only addressed the problem with LANG setting. The main cause of the bug is that we are not connecting to CUPS if CUPS listens to local domain socket as well as localhost. Since Java cannot connect to domain socket which is CUPS' default server, we fail and fall back to shell command in getting printers and status of printers e.g. accepting job. We should be able to still use CUPS and we can fix this by setting CUPS server to localhost.
05-12-2006