question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Summary

i’m using below devfile.yaml . i have specified is a javacontainer and selenium novnc-container

schemaVersion: 2.1.0
metadata:
  name: cbfsel-repo
projects:
  - name: cbfsel-project
    git:
      checkoutFrom:
        revision: master
      remotes:
        origin: https://gitlab.myorganization/repository.git
components:
  - container:
      image: 'quay.io/devfile/universal-developer-image:ubi8-0e189d9'
      memoryLimit: 2G
      endpoints:
        - exposure: none
          name: debug
          protocol: tcp
          targetPort: 5005
        - exposure: public
          name: 8080-http
          protocol: http
          targetPort: 8080
      volumeMounts:
        - name: m2volume
          path: /home/user/.m2
    name: javacontainer
  - container:
      image: 'mycustomdockerregistry/standalone-chrome:4.1.2-20220217'
      memoryLimit: 2G
      endpoints:
        - exposure: public
          name: 4444-tcp
          protocol: tcp
          targetPort: 4444
        - exposure: public
          name: 5900-tcp
          protocol: tcp
          targetPort: 5900
        - exposure: public
          name: 7900-http
          protocol: http
          targetPort: 7900
          secure: true
      volumeMounts:
        - name: seleniumvolume
          path: /home/user/.m2
    name: seleniumcontainer
  - name: m2volume
    volume:
      size: 2G
  - name: seleniumvolume
    volume:
      size: 2G
commands:
  - exec:
      commandLine: mvn clean package -DskipTests
      component: javacontainer
      group:
        isDefault: true
        kind: build
      label: 'build project using maven'
      workingDir: '${PROJECT_SOURCE}'
    id: mvnpackage

The javaprogram in the workspace will make use of the selenium-novnc container to run tests on webpages. when i execute the javaprogram, the first page of my test appears in the selenium-novnc website, but then it fails with below error(i understand below stacktrace shows some of my classnames, but its fine).

vTAPRegression.moduledrivers.DuckduckgoDriver@41200e0c|Error: Failed in executing component |vTap_duck_Operation| |java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at cbf.engine.BaseModuleDriver.invokeMethod(BaseModuleDriver.java:103)
        at cbf.engine.BaseModuleDriver.eval(BaseModuleDriver.java:56)
        at cbf.engine.BaseModuleDriver.perform(BaseModuleDriver.java:50)
        at cbf.engine.BaseAppDriver.perform(BaseAppDriver.java:61)
        at cbf.engine.TestCaseRunner.performComponent(TestCaseRunner.java:260)
        at cbf.engine.TestCaseRunner.access$400(TestCaseRunner.java:41)
        at cbf.engine.TestCaseRunner$4.run(TestCaseRunner.java:234)
        at cbf.engine.TestResultTracker.track(TestResultTracker.java:135)
        at cbf.engine.TestCaseRunner.runComponent(TestCaseRunner.java:229)
        at cbf.engine.TestCaseRunner$3.run(TestCaseRunner.java:168)
        at cbf.engine.TestResultTracker.track(TestResultTracker.java:135)
        at cbf.engine.TestCaseRunner.runStep(TestCaseRunner.java:160)
        at cbf.engine.TestCaseRunner$2.run(TestCaseRunner.java:139)
        at cbf.engine.TestResultTracker.track(TestResultTracker.java:135)
        at cbf.engine.TestCaseRunner.runIteration(TestCaseRunner.java:132)
        at cbf.engine.TestCaseRunner.access$200(TestCaseRunner.java:41)
        at cbf.engine.TestCaseRunner$1.run(TestCaseRunner.java:113)
        at cbf.engine.TestResultTracker.track(TestResultTracker.java:135)
        at cbf.engine.TestCaseRunner.runTestCase(TestCaseRunner.java:89)
        at cbf.engine.Engine.runTestCase(Engine.java:48)
        at cbf.engine.TestSetRunner$4.run(TestSetRunner.java:146)
        at cbf.engine.TestResultTracker.track(TestResultTracker.java:135)
        at cbf.engine.TestSetRunner.runTestInstance(TestSetRunner.java:130)
        at cbf.engine.TestSetRunner$3.run(TestSetRunner.java:107)
        at cbf.engine.TestResultTracker.track(TestResultTracker.java:135)
        at cbf.engine.TestSetRunner.runTestsetRerun(TestSetRunner.java:98)
        at cbf.engine.TestSetRunner$1.run(TestSetRunner.java:65)
        at cbf.engine.TestResultTracker.track(TestResultTracker.java:135)
        at cbf.engine.TestSetRunner.runTestSet(TestSetRunner.java:60)
        at cbf.engine.Engine.runTestSet(Engine.java:42)
        at cbf.engine.TestSetRunner.runTestSetInstance(TestSetRunner.java:183)
        at cbf.runner.MainRunner.<init>(MainRunner.java:61)
        at cbf.runner.MainRunner.main(MainRunner.java:53)
Caused by: java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
        at java.desktop/sun.awt.HeadlessToolkit.getScreenSize(HeadlessToolkit.java:186)
        at cbf.reporting.ScreenDumpManager.dumpScreen(ScreenDumpManager.java:154)
        at cbf.reporting.ScreenDumpManager.log(ScreenDumpManager.java:122)
        at cbf.engine.TestResultTracker.log(TestResultTracker.java:177)
        at cbf.engine.TestResultLogger.log(TestResultLogger.java:159)
        at cbf.engine.TestResultLogger.passed(TestResultLogger.java:86)
        at vTAPRegression.moduledrivers.DuckduckgoDriver.vTap_duck_Operation(DuckduckgoDriver.java:42)
        ... 37 more

i noticed this error Caused by: java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it. . i’m not sure how to fix this.

i tried adding export DISPLAY=:0 , export DISPLAY=localhost:0.0, export DISPLAY=:0.0 , it didn’t work

below is the operating system detail of the `java container image

please let me know how to fix this problem

Relevant information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tolushacommented, May 11, 2022
1reaction
tolushacommented, May 11, 2022

I tried to set environment variable within the container using export DISPLAY=0.0 and few other values, but it didnot work.

I believe it won’t work. It works only for current terminal session.

The commands mentioned above requires sudo permission

I don’t think that it is possible to install something that requires sudo rights when workspace is up and running. I recommend to build your own image on top of universal one and install there anything your need (plus set any environment variables) .

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - "No X11 DISPLAY variable" - what does it mean?
HeadlessException : No X11 DISPLAY variable was set, but this program performed an operation which requires it. java.awt.HeadlessException: No X11 DISPLAY ...
Read more >
Meaning and Resolving “No X11 DISPLAY” and Related Errors
HeadlessException : No X11 DISPLAY variable was set, but this program performed an operation which requires it.
Read more >
The launcheradmin.sh script generates a "No X11 DISPLAY ...
The launcheradmin.sh script generates a "No X11 DISPLAY variable was set, but this program performed an operation which requires it" error ...
Read more >
No X11 DISPLAY variable was set, but this program ...
1 Answer 1 · Ensure xauth is installed on target · In /etc/sshd_config set X11Forwarding yes · Run ssh with -vv to check...
Read more >
"No X11 DISPLAY variable was set, but this program ... - ERROR
This error occurs when an application tries to open the Graphical User Interface (GUI) but there is no Windows server available on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found