quarkusio/quarkus · error · UnsupportedOperationException
Printing is not supported with Quarkus AWT extension.
Error message
Printing is not supported with Quarkus AWT extension.
What it means
The Quarkus AWT extension supports only server-side, headless mode and explicitly cuts the dependency on printing. It substitutes sun.awt.windows.WToolkit.getPrintJob to throw UnsupportedOperationException whenever printing is attempted. This is intentional: java.awt.PrintJob is not available in Quarkus apps using the AWT extension.
Source
Thrown at extensions/awt/runtime/src/main/java/io/quarkus/awt/runtime/JDKSubstitutions.java:160
"filename.Wingdings=WINGDING.TTF\n";
Files.writeString(configFile, minimalConfig, StandardCharsets.UTF_8);
}
} catch (IOException e) {
throw new UncheckedIOException("Failed to write Windows " + configFile.toAbsolutePath(), e);
}
}
}
/**
* Cut the dependency on Swing and Printing - we support server side, headless mode.
* TODO: If an extension in Quarkiverse complains, we revisit it here.
*/
@TargetClass(className = "sun.awt.windows.WToolkit", onlyWith = IsWindows.class)
final class Target_sun_awt_windows_WToolkit {
@Substitute
public PrintJob getPrintJob(Frame frame, String jobtitle, Properties props) {
throw new UnsupportedOperationException("Printing is not supported with Quarkus AWT extension.");
}
@Substitute
public PrintJob getPrintJob(Frame frame, String jobtitle, JobAttributes jobAttributes, PageAttributes pageAttributes) {
throw new UnsupportedOperationException("Printing is not supported with Quarkus AWT extension.");
}
}
/**
* Cut ties to windowing, desktop
* TODO: If an extension in Quarkiverse complains, we revisit it here.
*/
@TargetClass(className = "sun.awt.windows.WObjectPeer", onlyWith = IsWindows.class)
final class Target_sun_awt_windows_WObjectPeer {
@Substitute
private static void initIDs() {
// no-op, no pData, destroyed, target
}View on GitHub (pinned to e1c734241f)
Solutions
- Remove or avoid the code path calling getPrintJob; render to images/streams instead
- Configure the offending library to a non-printing (image/stream) output mode
- Exclude printing-related dependencies that probe AWT printing at runtime
Example fix
// before PrintJob job = Toolkit.getDefaultToolkit().getPrintJob(frame, "doc", props); // after: render headlessly instead BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g = img.createGraphics(); component.paint(g);
Defensive patterns
Strategy: validation
Validate before calling
if (Toolkit.getDefaultToolkit() instanceof sun.awt.windows.WToolkit) {
throw new IllegalStateException("Printing is unsupported under Quarkus AWT extension");
} Type guard
static boolean printingSupported(GraphicsEnvironment env) {
return !env.isHeadless(); // in Quarkus AWT it is always headless; treat printing as unsupported
} Prevention
- Never call Toolkit.getPrintJob in Quarkus AWT applications
- Render to images or PDF streams instead of using AWT printing
- Audit third-party imaging libraries for hidden print code paths
When it happens
Trigger: Calling Toolkit.getDefaultToolkit().getPrintJob(frame, jobtitle, props) on a Windows JVM/native-image with the Quarkus AWT extension present — the substituted method always throws.
Common situations: A library that lazily resolves a PrintJob (some imaging/reporting libs probe printing); migrating a Swing app snippet into a Quarkus service; Windows-specific toolkit substitution triggering print code paths.
Related errors
- Failed to write Windows ${configFile.toAbsolutePath()}
- Add AWT Quarkus extension to enable Java2D/ImageIO. Addition
- Not Allowed
- .pfa font files are not supported. Use TrueType fonts, i.e.
- .pfb font files are not supported. Use TrueType fonts, i.e.
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/593c9d9fb59ed709.
Report an issue: GitHub.