JDK-5109523 : PrintServiceLookup on Linux does not show any printers, while jre1.4.2_05 does
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 5.0,5.0u1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2004-09-30
  • Updated: 2012-10-09
  • Resolved: 2004-10-27
Related Reports
Duplicate :  
Duplicate :  
Description
ULL PRODUCT VERSION :
java version "1.5.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Suse 9.1
Linux testsystem 2.6.5-7.104-default #1 Wed Jul 28 16:42:13 UTC 2004 i686 i686 i386 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
PrintService does not return any printers on Linux. Using same code with java 1.4.2 does return all printers.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the attached code

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A list with names of printers installed on the system
ACTUAL -
No printers where found. when I use jdk 1.4.2_05 it does work

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.print.*;
import javax.print.*;
import javax.print.attribute.*;
import java.text.*;
import javax.print.attribute.standard.*;

public class ShowPrinters {
    
    public ShowPrinters() {
    }
    
    public static void main(String[] args) {
        DocFlavor myFormat = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        PrintService[] services =PrintServiceLookup.lookupPrintServices(myFormat, aset);
        System.out.println("The following printers are available");
        for (int i=0;i<services.length;i++) {
            System.out.println("  service name: "+services[i].getName());
        }
    }
}
---------- END SOURCE ----------
###@###.### 10/7/04 16:04 GMT

Comments
WORK AROUND java -Djava.net.preferIPv4Stack=true ###@###.### 10/27/04 23:24 GMT
27-10-2004

EVALUATION Our theory is that CUPS is running but not configured and the CUPS binaries for the lpc command has not been installed in the default locations so 1.4.2 was not using the CUPS version of that command which would have shown the same problem. Need user to provide additional information such as what Linux distro and to perform some tests. ###@###.### 2004-09-30 ============================ Need the output of these: /etc/init.d/cups status /usr/sbin/lpc -a status /usr/bin/lpstat -v Marking as incomplete. ###@###.### 10/6/04 20:28 GMT I can reproduce this using Suse 9.1 and bug is caused by an error when attempting to get the output stream of the http connection. Needs further investigation why this is happening but we should at least detect this error and bail out to use the old way of looking up services, i.e. use of lpstat or lpc. ###@###.### 10/12/04 20:41 GMT This is caused by a bug in the java networking code (5087907). That bug is not new to JDK 1.5 but printing in 1.4.2 didn't call the buggy code. The new direct CUPS support in JDK1.5 does however and so is vulnerable to it. Here's the problem. On Suse 9 IPV6 is enabled and the /etc/hosts has some V6 format addresses. JDK prefers IP V4 addresses unless you tell it otherwise via a system property, but the logic that handles that is backwards! So by default it will return an IP V6 address for localhost, and when you try to connect using PIV4 I suppose, it fails! The good news is that this is bug 5087907 and its slated to be fixed in 1.5.0_01. I've verified that running with an internal build (1.5.0_01-b05) that the problem is indeed fixed. There's also a workaround : java -Djava.net.preferIPv4Stack=true ###@###.### 10/27/04 23:24 GMT
27-10-0004