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

UnavailableServiceException in ServiceManager.lookup("javax.jnlp.PrintService");

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 9
    • 7u55
    • client-libs
    • 2d
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      1.7.0_55

      ADDITIONAL OS VERSION INFORMATION :
      Windows version 6.1.7600

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Printing to a printer with temporary connection problems

      A DESCRIPTION OF THE PROBLEM :
      When an applet tries to print using jnlp everything goes well if the printer has no error. But when a a previous print job is hangng on the printer because of some connection problem, the applet receives a UnavailableServiceException in ServiceManager.lookup("javax.jnlp.PrintService"), and so it's unable to spool the print job.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      PrintService ps = (PrintService) ServiceManager .lookup("javax.jnlp.PrintService");
       // Throws Exception when previous print job is in error
      ps.print(this));

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The printer is configured and accepting jobs in other windows software. The applet should get the same behavior and should be able to send new jobs to the print spooler.
      ACTUAL -
      The applet can't get a PrintService to spool the print job. Instead it gets a UnavailableServceException when doing ServiceManager.lookup()

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error. Just an exception thrown.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package pt.moredata.applet;

      import java.applet.Applet;
      import java.awt.Color;
      import java.awt.Graphics;
      import java.awt.Graphics2D;
      import java.awt.print.PageFormat;
      import java.awt.print.Printable;
      import java.awt.print.PrinterException;

      import javax.jnlp.PrintService;
      import javax.jnlp.ServiceManager;
      import javax.jnlp.UnavailableServiceException;

      public class TestApplet extends Applet implements Printable {

      /**
      *
      */
      private static final long serialVersionUID = 1L;

      public void init() {
      setBackground(new Color(250, 250, 250));

      try {

      PrintService ps = (PrintService) ServiceManager
      .lookup("javax.jnlp.PrintService");
      ps.print(this);
      } catch (UnavailableServiceException ue) {
      System.out.println("Unavailable Service: " + ue.getMessage());
      ue.printStackTrace();
      } catch (Exception e) {
      System.out.println("ERROR:" + e.getMessage());
      e.printStackTrace();
      }
      }

      public int print(Graphics g, PageFormat pf, int page)
      throws PrinterException {

      if (page > 0) {
      return NO_SUCH_PAGE;
      }

      Graphics2D g2d = (Graphics2D) g;
      g2d.translate(pf.getImageableX(), pf.getImageableY());

      g.drawString("TEST PRINT", 10, 10);

      return PAGE_EXISTS;
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround. It's annoying for the user. Compares badly with windows native software.

            aivanov Alexey Ivanov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: