JDK-8044617 : UnavailableServiceException in ServiceManager.lookup("javax.jnlp.PrintService");
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7u55
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2014-05-09
  • Updated: 2014-08-18
  • Resolved: 2014-08-18
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.
JDK 9
9Resolved
Related Reports
Duplicate :  
Description
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.


Comments
This bug describes the same as issue as JDK-8046007 from the applet point of view, so the root cause is the same for both bugs.
18-08-2014