JDK-6699864 : printDialog throws NPE on ubuntu linux
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2008-05-09
  • Updated: 2010-04-04
  • Resolved: 2008-05-10
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
~/aa/pp/j$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-b05, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
sun-java6-jdk   6-03-0ubuntu2 from ubuntu's repositories
~/aa/pp/j$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-b05, mixed mode)
user1@dualVSTA:~/aa/pp/j$


EXTRA RELEVANT SYSTEM CONFIGURATION :
ASROCK 939Dual-VSTA motherboard
same on another 64 bit AMD board,
but I forgot its name



A DESCRIPTION OF THE PROBLEM :
This program will display the printDialog window using XPx64,
but gives the following exception output in ubuntu.

//################### Test printDialog show only ############

import java.awt.print.PrinterJob;

public class Test {

  Test test;

  public static void main(String[]args) {

    Test test=new Test(); test.test=test; test.main2(); //escape static

  }

  protected void main2() { //escapes static

    PrinterJob prJ;

    prJ=PrinterJob.getPrinterJob();

    System.out.println("------------------LOOK FOR & CLICK PRINT DIALOG");

    if(prJ.printDialog()) { //Doesn't show window in Linux, but does in Windows

    } //pause("after printDialog");

  }

} 


javac Test.java

java Test

------------------LOOK FOR & CLICK PRINT DIALOG

Exception in thread "main" java.lang.NullPointerException: null attribute

        at sun.print.IPPPrintService.isAttributeValueSupported(IPPPrintService.java:1147)

        at sun.print.ServiceDialog$OrientationPanel.updateInfo(ServiceDialog.java:2121)

        at sun.print.ServiceDialog$PageSetupPanel.updateInfo(ServiceDialog.java:1263)

        at sun.print.ServiceDialog.updatePanels(ServiceDialog.java:437)

        at sun.print.ServiceDialog.initPrintDialog(ServiceDialog.java:195)

        at sun.print.ServiceDialog.<init>(ServiceDialog.java:124)

        at javax.print.ServiceUI.printDialog(ServiceUI.java:188)

        at sun.print.RasterPrinterJob.printDialog(RasterPrinterJob.java:855)

        at sun.print.PSPrinterJob.printDialog(PSPrinterJob.java:421)

        at Test.main2(Test.java:12)

        at Test.main(Test.java:6)


Java is supposed to be a ���write-once, run anywhere��� language.
The forum participants don't seem to be able to answer this.
The students at the local chapter of ACM where they install ubuntu didn't either.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile and try the program as shown.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
shows printDialog window in MS windows,
bur gives exception in linux
ACTUAL -
------------------LOOK FOR & CLICK PRINT DIALOG
Exception in thread "main" java.lang.NullPointerException: null attribute
        at sun.print.IPPPrintService.isAttributeValueSupported(IPPPrintService.java:1147)
        at sun.print.ServiceDialog$OrientationPanel.updateInfo(ServiceDialog.java:2121)
        at sun.print.ServiceDialog$PageSetupPanel.updateInfo(ServiceDialog.java:1263)
        at sun.print.ServiceDialog.updatePanels(ServiceDialog.java:437)
        at sun.print.ServiceDialog.initPrintDialog(ServiceDialog.java:195)
        at sun.print.ServiceDialog.<init>(ServiceDialog.java:124)
        at javax.print.ServiceUI.printDialog(ServiceUI.java:188)
        at sun.print.RasterPrinterJob.printDialog(RasterPrinterJob.java:855)
        at sun.print.PSPrinterJob.printDialog(PSPrinterJob.java:421)
        at Test.main2(Test.java:12)
        at Test.main(Test.java:6)




ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NullPointerException: null attribute
        at sun.print.IPPPrintService.isAttributeValueSupported(IPPPrintService.java:1147)
        at sun.print.ServiceDialog$OrientationPanel.updateInfo(ServiceDialog.java:2121)
        at sun.print.ServiceDialog$PageSetupPanel.updateInfo(ServiceDialog.java:1263)
        at sun.print.ServiceDialog.updatePanels(ServiceDialog.java:437)
        at sun.print.ServiceDialog.initPrintDialog(ServiceDialog.java:195)
        at sun.print.ServiceDialog.<init>(ServiceDialog.java:124)
        at javax.print.ServiceUI.printDialog(ServiceUI.java:188)
        at sun.print.RasterPrinterJob.printDialog(RasterPrinterJob.java:855)
        at sun.print.PSPrinterJob.printDialog(PSPrinterJob.java:421)
        at Test.main2(Test.java:12)
        at Test.main(Test.java:6)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
//################### Test printDialog show only ############

import java.awt.print.PrinterJob;

public class Test {

  Test test;

  public static void main(String[]args) {

    Test test=new Test(); test.test=test; test.main2(); //escape static

  }

  protected void main2() { //escapes static

    PrinterJob prJ;

    prJ=PrinterJob.getPrinterJob();

    System.out.println("------------------LOOK FOR & CLICK PRINT DIALOG");

    if(prJ.printDialog()) { //Doesn't show window in Linux, but does in Windows

    } //pause("after printDialog");

  }

} 


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

CUSTOMER SUBMITTED WORKAROUND :
just use microsoft