Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java PrintDialog doesn't work with cups on a linux machine, only a NullPointerException: null attribute is received. #2610

michaelrsweet opened this issue Nov 26, 2007 · 2 comments


Copy link

@michaelrsweet michaelrsweet commented Nov 26, 2007

Version: 1.3.4 User: stefan_sitte

Java-Print-Dialog doesn't work with the current cups realease (1.3.4) because of the following NullPointerException:

Exception in thread "main" java.lang.NullPointerException: null attribute
at sun.print.IPPPrintService.isAttributeValueSupported(
at sun.print.ServiceDialog$OrientationPanel.updateInfo(
at sun.print.ServiceDialog$PageSetupPanel.updateInfo(
at sun.print.ServiceDialog.updatePanels(
at sun.print.ServiceDialog.initPrintDialog(
at sun.print.ServiceDialog.(
at javax.print.ServiceUI.printDialog(
at sun.print.RasterPrinterJob.printDialog(
at sun.print.PSPrinterJob.printDialog(
at Main.main(

When i execute following cource code (open only a java print dialog), i get the NullPointerException.

import java.awt.print.PrinterJob;

public class Main {

public static void main(String[] args) {
    PrinterJob printJob = PrinterJob.getPrinterJob();


My system:
KDE version: 3.5.8-7.fc8
Machine: i686
used java versions (with all the same problem):
Version: 1.3.4
Release: 2.fc8

The exception is caused by a missing orientation attribute. The ServiceDialog wants to get the attribute, doesn't find the orientation-attribute and then asks for the default-orientation-attribute, but the orientation-attribute is not supported by the printers.
code form ServiceDialog:2119:
public void updateInfo() {
OrientationRequested or = (OrientationRequested)asCurrent.get(orCategory);
if (or == null ||
!psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) {

    or = (OrientationRequested)psCurrent.getDefaultAttributeValue(orCategory);
    // need to validate if default is not supported

// this call throws the NullPointerException, because: or is null
if (!psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) {
or = null;
Object values =
if (values instanceof OrientationRequested[]) {
OrientationRequested[] orValues =
if (orValues.length > 1) {
// get the first in the list
or = orValues[0];

    if (or == null) {
        or = OrientationRequested.PORTRAIT;


I searched for the problem and found that in the function IPPPrintService::readIPPResponse() where the attributes are achieved from a (KM3050 is the name of a printer on my system), but the returned attribute-set does not contain a orientation attribute.

In my mind, the problem depends on cups because it doesn't send any orientation attribute.


  • on windows (without cups) the java print dialog works just fine.
  • with a attribute set param for the printdialog it is just the same result
    PrinterJob printJob = PrinterJob.getPrinterJob();
    PrintRequestAttributeSet prnSet = new HashPrintRequestAttributeSet();
    if (printJob.printDialog(prnSet) == false) {
  • "update" to older cups releases is no option

I apologize for my "bad" english but it's not my native language.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Nov 26, 2007 User: stefan_sitte

Now there is also a bug report in SDN (Sun Developer Network):

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Nov 26, 2007 User: mike

This is a known bug in Java - basically their IPP implementation makes many assumptions about what will be returned in an IPP request and doesn't handle the "no value" value of orientation-requested. As a result, it stops processing the IPP response (without producing an error/exception about it) and bombs in the print dialog instead.

Please contact Sun for assistance in this Java bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant