Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8032693

javax.print.PrintService does not find any CUPS-Printers on Linux

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • Resolved In Build:
      b06
    • OS:
      linux

      Backports

        Description

        FULL PRODUCT VERSION :
        Java(TM) SE Runtime Environment (build 1.8.0-ea-b124)
        Java HotSpot(TM) 64-Bit Server VM (build 25.0-b66, mixed mode)

        (this also happened with build 1.8.0-ea-b123)

        ADDITIONAL OS VERSION INFORMATION :
        Linux 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
        No LSB modules are available.
        Distributor ID: Ubuntu
          Description: Ubuntu 13.10
          Release: 13.10
        Codename: saucy


        EXTRA RELEVANT SYSTEM CONFIGURATION :
        ii cups 1.7.0~rc1-0ubuntu5.2 amd64

        A DESCRIPTION OF THE PROBLEM :
        When trying to print to a CUPS-Printer using JDK 1.8EA the PrintService will not find any Printer. Other Versions of Java (1.6, 1.7) will find and list them.

        I used the Test-Program from Bug #6181488:
        ---------------- Services_getStatus.java ------------------------
        import javax.print.*;
        import javax.print.attribute.*;
        import javax.print.attribute.standard.*;

        public class Services_getStatus {
             public static void main(String[] args){

             PrintService defServ = PrintServiceLookup.lookupDefaultPrintService();
             System.out.println("Default PrintService: "+defServ);

             PrintService[] serv = PrintServiceLookup.lookupPrintServices(null, null);
             if (serv.length==0) {
                 System.out.println("no PrintService found");
             } else {
                 System.out.println("number of Services "+serv.length);
             }


             for (int i = 0; i<serv.length ;i++) {
                 PrintServiceAttributeSet psa = serv[i].getAttributes();
                 System.out.println("printer name "+(i+1)+" "+psa.get(PrinterName.class));
                 System.out.println("accepting "+psa.get(PrinterIsAcceptingJobs.class));
             }

             }
        }
        -----------------------

        -- Output with JDK1.8 --

        Default PrintService: null
        no PrintService found

        -----------------------

        -- Output with JDK 1.7 --

        Default PrintService: null
        number of Services 6
        printer name 1 hp2055
        accepting accepting-jobs
        printer name 2 hp2055
        accepting accepting-jobs
        printer name 3 Kopierer
        accepting accepting-jobs
        printer name 4 Kopierer
        accepting accepting-jobs
        printer name 5 LaserJet
        accepting accepting-jobs
        printer name 6 LaserJet
        accepting accepting-jobs



        REGRESSION. Last worked in version 7u51

        ADDITIONAL REGRESSION INFORMATION:
        Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
        Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile Code from above and run
        java Services_getStatus
        on a Linux-Machine with CUPS-Printers

        or try to print from an Application like NetBeans (7.4)

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        A list of CUPS-Printers
        (Note: due to Bug #6181488 the Default-Printer is null)
        Default PrintService: null
        number of Services 6
        printer name 1 hp2055
        accepting accepting-jobs
        printer name 2 hp2055
        accepting accepting-jobs
        printer name 3 Kopierer
        accepting accepting-jobs
        printer name 4 Kopierer
        accepting accepting-jobs
        printer name 5 LaserJet
        accepting accepting-jobs
        printer name 6 LaserJet
        accepting accepting-jobs

        ACTUAL -
        Default PrintService: null
        no PrintService found


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import javax.print.*;
        import javax.print.attribute.*;
        import javax.print.attribute.standard.*;

        public class Services_getStatus {
             public static void main(String[] args){

             PrintService defServ = PrintServiceLookup.lookupDefaultPrintService();
             System.out.println("Default PrintService: "+defServ);

             PrintService[] serv = PrintServiceLookup.lookupPrintServices(null, null);
             if (serv.length==0) {
                 System.out.println("no PrintService found");
             } else {
                 System.out.println("number of Services "+serv.length);
             }


             for (int i = 0; i<serv.length ;i++) {
                 PrintServiceAttributeSet psa = serv[i].getAttributes();
                 System.out.println("printer name "+(i+1)+" "+psa.get(PrinterName.class));
                 System.out.println("accepting "+psa.get(PrinterIsAcceptingJobs.class));
             }

             }
        }

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

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                prr Philip Race
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: