-
Bug
-
Resolution: Unresolved
-
P3
-
17.0.12, 21.0.4, 22.0.2, 23
ADDITIONAL SYSTEM INFORMATION :
Windows 2022 Server with Java 21.0.4
A DESCRIPTION OF THE PROBLEM :
After upgrading from Java 21.0.3 to 21.0.4 we observe massive test failures during our nightly builds. Our test for our desktop application are executed with Jenkins running as a windows service. We identifiedJDK-8185862 as the culprit: java.awt.headless is now set to true and causes numerous HeadlessExceptions as to be expected when trying to open some Windows or using other awt-Methods. So, as a workaround we tried explicitly set "-Djava.awt.headless=false" to get the old behavior. Unfortunately now we get a "java.awt.AWTError: no screen devices" instead.
This is a big problem since out application is not intended to be fully compatible with headless environments and now tests that were running fine are unable to be executed with the new Java version. Even when starting Jenkins not as a service but start it via remote desktop and disconnect, the errors reappear. That will keep us from updating Java and integrating security fixes since it would be a huge amount of work to make our application fully headless compatible without much use beside getting out tests running again.
REGRESSION : Last worked in version 21
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
import java.awt.Window;
public class Main {
public static void main(String[] args) {
Window window = new Window(null);
}
}
compile the code above and execute it in an environment without a UI session.
> java Main
Exception in thread "main" java.awt.HeadlessException:
The application does not have desktop access,
but this program performed an operation which requires it.
at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:164)
at java.desktop/java.awt.Window.init(Window.java:501)
at java.desktop/java.awt.Window.<init>(Window.java:453)
at java.desktop/java.awt.Window.<init>(Window.java:578)
at Main.main(Main.java:4)
>java -Djava.awt.headless=false Main
Exception in thread "main" java.awt.AWTError: no screen devices
at java.desktop/sun.awt.Win32GraphicsEnvironment.getDefaultScreenDevice(Win32GraphicsEnvironment.java:101)
at java.desktop/java.awt.Window.initGC(Window.java:493)
at java.desktop/java.awt.Window.init(Window.java:512)
at java.desktop/java.awt.Window.<init>(Window.java:453)
at java.desktop/java.awt.Window.<init>(Window.java:578)
at Main.main(Main.java:4)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Simply works as in Java 21.0.3
ACTUAL -
HeadlessException/AWTException
---------- BEGIN SOURCE ----------
import java.awt.Window;
public class Main {
public static void main(String[] args) {
Window window = new Window(null);
}
}
---------- END SOURCE ----------
FREQUENCY : always
Windows 2022 Server with Java 21.0.4
A DESCRIPTION OF THE PROBLEM :
After upgrading from Java 21.0.3 to 21.0.4 we observe massive test failures during our nightly builds. Our test for our desktop application are executed with Jenkins running as a windows service. We identified
This is a big problem since out application is not intended to be fully compatible with headless environments and now tests that were running fine are unable to be executed with the new Java version. Even when starting Jenkins not as a service but start it via remote desktop and disconnect, the errors reappear. That will keep us from updating Java and integrating security fixes since it would be a huge amount of work to make our application fully headless compatible without much use beside getting out tests running again.
REGRESSION : Last worked in version 21
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
import java.awt.Window;
public class Main {
public static void main(String[] args) {
Window window = new Window(null);
}
}
compile the code above and execute it in an environment without a UI session.
> java Main
Exception in thread "main" java.awt.HeadlessException:
The application does not have desktop access,
but this program performed an operation which requires it.
at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:164)
at java.desktop/java.awt.Window.init(Window.java:501)
at java.desktop/java.awt.Window.<init>(Window.java:453)
at java.desktop/java.awt.Window.<init>(Window.java:578)
at Main.main(Main.java:4)
>java -Djava.awt.headless=false Main
Exception in thread "main" java.awt.AWTError: no screen devices
at java.desktop/sun.awt.Win32GraphicsEnvironment.getDefaultScreenDevice(Win32GraphicsEnvironment.java:101)
at java.desktop/java.awt.Window.initGC(Window.java:493)
at java.desktop/java.awt.Window.init(Window.java:512)
at java.desktop/java.awt.Window.<init>(Window.java:453)
at java.desktop/java.awt.Window.<init>(Window.java:578)
at Main.main(Main.java:4)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Simply works as in Java 21.0.3
ACTUAL -
HeadlessException/AWTException
---------- BEGIN SOURCE ----------
import java.awt.Window;
public class Main {
public static void main(String[] args) {
Window window = new Window(null);
}
}
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8340992 Headless Mode on Windows no Longer Works as Before
-
- Closed
-
- relates to
-
JDK-8185862 AWT Assertion Failure in ::GetDIBits(hBMDC, hBM, 0, 1, 0, gpBitmapInfo, 0) 'awt_Win32GraphicsDevice.cpp', at line 185
-
- Resolved
-