Getting " No X11 DISPLAY variable was set, but this program performed an operation which requires it."

9.5k Views Asked by At

I am running a test on AWS through jenkins integration, this test requires a file to be uploaded, and to upload a file a upload(File Explorer) window is opened, which is triggering the error


[java] [INFO ] [2:53:49PM] Thread-1 (TestMethodRunner.java:188) - [java] No X11 DISPLAY variable was set, but this program performed an operation which requires it. [java] [INFO ] [2:53:49PM] Thread-1 (TestMethodRunner.java:189) - java.awt.HeadlessException: [java] No X11 DISPLAY variable was set, but this program performed an operation which requires it. [java] at sun.awt.HeadlessToolkit.getSystemClipboard(HeadlessToolkit.java:307) [java] at com.proquest.apps.etd.pqaf.layer.FileUploadWindow.uploadingFile(FileUploadWindow.java:50) [java] at com.proquest.apps.etd.regression.tests.SmokeTest.smokeTest(SmokeTest.java:100) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [java] at java.lang.reflect.Method.invoke(Method.java:606) [java] at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) [java] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) [java] at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) [java] at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) [java] at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) [java] at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) [java] at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:47) [java] at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:47) [java] at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:47) [java] at org.junit.rules.RunRules.evaluate(RunRules.java:18) [java] at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) [java] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) [java] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) [java] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) [java] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) [java] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) [java] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) [java] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) [java] at org.junit.runners.ParentRunner.run(ParentRunner.java:300) [java] at org.junit.runner.JUnitCore.run(JUnitCore.java:157) [java] at org.junit.runner.JUnitCore.run(JUnitCore.java:136) [java] at com.proquest.testing.TestMethodRunner.runUnitTest(TestMethodRunner.java:194) [java] at com.proquest.testing.TestMethodRunner.run(TestMethodRunner.java:62) [java] at com.proquest.testing.SimpleThread.run(SimpleThread.java:13)


  1. How to resolve this error, I can't use putty to enable X11, the tests are ran through Jenkins , the test is executed every day automatically at the scheduled time, so i have to make it dynamic?
  2. Is there any ivy dependency for the "No X11 DISPLAY variable was set and Headless Exception" that can be used.
1

There are 1 best solutions below

1
On

If your build requires X11 access, you'll want to wrap your jenkins build with a virtual frame buffer. Jenkins has an available plugin to help with this called Xvfb.

Then you'll want to let Jenkins know to use this new display for your tests instead.

example:

export DISPLAY=:1.0

where 1.0 would be the name of your virtual X window.