-
Bug
-
Resolution: Fixed
-
P4
-
5.0u19, OpenJDK6, 6, 6u6
-
b28
-
x86
-
linux, linux_2.6, linux_suse_sles_11, linux_ubuntu
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2159806 | 6u10 | Jennifer Godinez | P3 | Resolved | Fixed | b20 |
JDK-2159894 | OpenJDK6 | Jennifer Godinez | P3 | Resolved | Fixed | b09 |
JDK-2175822 | 5.0u19 | Abhijit Saha | P2 | Resolved | Fixed | b02 |
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)
and
java version "1.7.0"
IcedTea Runtime Environment (build 1.7.0-b23)
IcedTea Server VM (build 1.7.0-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux nirvana.limasoftware.net 2.6.23.1-49.fc8 #1 SMP Thu Nov 8 21:41:26 EST 2007 i686 i686 i386 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Network printer
A DESCRIPTION OF THE PROBLEM :
We got a report to IcedTea bugzilla:
http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=81
Here is a copy from the original report for reference:
-------------
The example code from http://java.sun.com/javase/6/docs/technotes/guides/jps/spec/appendix_2DPrinterJob.fm.html#997825 throws a null pointer exception.
This is with Fedora 8 java-1.7.0-icedtea-devel:
$ javac Print2DPrinterJob.java
$ java Print2DPrinterJob
selected printer hp_LaserJet_1320_series
Exception in thread "main" java.lang.NullPointerException: null attribute
at
sun.print.IPPPrintService.isAttributeValueSupported(IPPPrintService.java:1176)
at
sun.print.ServiceDialog$OrientationPanel.updateInfo(ServiceDialog.java:2165)
at
sun.print.ServiceDialog$PageSetupPanel.updateInfo(ServiceDialog.java:1281)
at sun.print.ServiceDialog.initPageDialog(ServiceDialog.java:284)
at sun.print.ServiceDialog.<init>(ServiceDialog.java:261)
at sun.print.RasterPrinterJob.pageDialog(RasterPrinterJob.java:684)
at Print2DPrinterJob.<init>(Print2DPrinterJob.java:35)
at Print2DPrinterJob.main(Print2DPrinterJob.java:62)
If I comment out the calls to PrinterJob.PageDialog() and
PrinterJob.PrintDialog(), the print job goes through without throwing an
exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. download the test code from http://java.sun.com/javase/6/docs/technotes/guides/jps/spec/appendix_2DPrinterJob.fm.html#997825
2. javac Print2DPrinterJob.java
3. java Print2DPrinterJob
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Print dialog to appear.
ACTUAL -
The vm exits with a java.lang.NullPointerException.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NullPointerException: null attribute
at
sun.print.IPPPrintService.isAttributeValueSupported(IPPPrintService.java:1176)
at
sun.print.ServiceDialog$OrientationPanel.updateInfo(ServiceDialog.java:2165)
at
sun.print.ServiceDialog$PageSetupPanel.updateInfo(ServiceDialog.java:1281)
at sun.print.ServiceDialog.initPageDialog(ServiceDialog.java:284)
at sun.print.ServiceDialog.<init>(ServiceDialog.java:261)
at sun.print.RasterPrinterJob.pageDialog(RasterPrinterJob.java:684)
at Print2DPrinterJob.<init>(Print2DPrinterJob.java:35)
at Print2DPrinterJob.main(Print2DPrinterJob.java:62)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.awt.*;
import java.net.*;
import java.awt.image.*;
import java.awt.print.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
public class Print2DPrinterJob implements Printable {
public Print2DPrinterJob() {
/* Construct the print request specification.
* The print data is a Printable object.
* the request additonally specifies a job name, 2 copies, and
* landscape orientation of the media.
*/
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(OrientationRequested.LANDSCAPE);
aset.add(new Copies(2));
aset.add(new JobName("My job", null));
/* Create a print job */
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(this);
/* locate a print service that can handle the request */
PrintService[] services =
PrinterJob.lookupPrintServices();
if (services.length > 0) {
System.out.println("selected printer " + services[0].getName());
try {
pj.setPrintService(services[0]);
pj.pageDialog(aset);
if(pj.printDialog(aset)) {
pj.print(aset);
}
} catch (PrinterException pe) {
System.err.println(pe);
}
}
}
public int print(Graphics g,PageFormat pf,int pageIndex) {
if (pageIndex == 0) {
Graphics2D g2d= (Graphics2D)g;
g2d.translate(pf.getImageableX(), pf.getImageableY());
g2d.setColor(Color.black);
g2d.drawString("example string", 250, 250);
g2d.fillRect(0, 0, 200, 200);
return Printable.PAGE_EXISTS;
} else {
return Printable.NO_SUCH_PAGE;
}
}
public static void main(String arg[]) {
Print2DPrinterJob sp = new Print2DPrinterJob();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I think that the problem is in line 2162 (5 in this snippet) of
sun.print.ServiceDialog class:
1. OrientationRequested or = (OrientationRequested)asCurrent.get(orCategory);
2. if (or == null ||
3. !psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) {
4.
5. or = (OrientationRequested) psCurrent.
6. getDefaultAttributeValue(orCategory);
What happens is that in line 1 "or" is correctly initialized to the supplied
value (OrientationRequested.LANDSCAPE), but then
psCurrent.isAttributeValueSupported return false, forcing to query a default
value for the OrientationRequested attribute.
getDefaultAttributeValue contains this call:
if (!isAttributeCategorySupported(category)) {
return null;
}
So it looks to me like a circular reference, the key is not supported, so we
ask for a default value, but we don't have a default value because the key is
not supported.
The following patch should bypass the problem, but it's not tested (b23).
I think a better solution would be to fix this circular reference problem
adding support for OrientationRequested under linux.
------- cut --------
--- openjdk/jdk/src/solaris/classes/sun/print/IPPPrintService.java-orig 2007-11-25 20:26:20.000000000 +0100
+++ openjdk/jdk/src/solaris/classes/sun/print/IPPPrintService.java 2007-11-25 20:26:44.000000000 +0100
@@ -1173,7 +1173,7 @@
DocFlavor flavor,
AttributeSet attributes) {
if (attr == null) {
- throw new NullPointerException("null attribute");
+ return false;
}
if (flavor != null) {
if (!isDocFlavorSupported(flavor)) {
This is reproducible on Ubuntu 7.10 and Ubuntu 8.04 using openjdk6. I tried installing the latest CUPS (1.3.5) on Ubuntu 8.04 and the problem did not go away. I also noticed that some of the common attributes such as Orientation and Copies are reported as unsupported. I tested this with Xerox Phaser 5500 and used the ppd files available on xerox.com.
- backported by
-
JDK-2175822 Cross platform print dialog doesn't check for orientation being unsupported.
-
- Resolved
-
-
JDK-2159806 Cross platform print dialog doesn't check for orientation being unsupported.
-
- Resolved
-
-
JDK-2159894 Cross platform print dialog doesn't check for orientation being unsupported.
-
- Resolved
-
- duplicates
-
JDK-6741351 NullPointerException at PrinterJob.pageDialog() under Linux
-
- Closed
-
-
JDK-6693514 PrinterJob.printDialog() window not shown in ubuntu linux
-
- Closed
-
-
JDK-6699864 printDialog throws NPE on ubuntu linux
-
- Closed
-
-
JDK-6829489 PrintDialog not appear on sles11
-
- Closed
-