1

Sorry for the short question, and long explanation.

My local Clojure program runs fine and uses GUI controls but, when run from a server, it fails. Can you help?

I have been testing Clojure sample code on a headless Ubuntu (14.04) server. I run the programs in LightTable, and then run them again with LT connected to a Ubuntu repl.

The program that doesn't work for me is one that opens a file chooser dialog, in native OS X, so that I can upload a document to the server. It appears that some GUI resource that is found by my Macbook, is not found by the server program. I had it working once, for an hour and, websites that I use find the functionality, no problem.

I feel that I've gotten in a hellish state, trying to make this sample work, and I really need it to work.

I have VirtualBox extension pack, which should provide VRDE.

I have variously tried different server startup options, and ssh options. If I set environment variables, my client program fails to make use of the details.

The worst part for me is that, it did work - once. My efforts to make the working changes permanent have broke it, again. Despite snapshot restores and a restore of my Macbook, I can't get this setup to work any longer.

In short, a GUI program that runs on the client, encounters problems when run from the server. Please help. I've been stuck for days.

I don't know if it helps but, I have Xauth installed and Webmin. Webmin is described as 'a web-based GUI admin tool for Linux.'

I've been advised to use Java WebStart but, I read that this is included and used automatically. I can't see a solution in investigating it, further.

I've provided the full error message, as copied from LightTable, in case that helps you to help me:

**java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
GraphicsEnvironment.java:207 java.awt.GraphicsEnvironment.checkHeadless
          Window.java:535 java.awt.Window.<init>
           Frame.java:420 java.awt.Frame.<init>
           Frame.java:385 java.awt.Frame.<init>
          JFrame.java:174 javax.swing.JFrame.<init>
         (Unknown Source) com.ociweb.swing.proxy$javax.swing.JFrame$ActionListener$c1f703.<init>
         (Unknown Source) com.ociweb.swing$eval7839.invoke
       Compiler.java:6703 clojure.lang.Compiler.eval
       Compiler.java:6666 clojure.lang.Compiler.eval
            core.clj:2927 clojure.core/eval
              eval.clj:77 lighttable.nrepl.eval/->result
             AFn.java:156 clojure.lang.AFn.applyToHelper
             AFn.java:144 clojure.lang.AFn.applyTo
             core.clj:626 clojure.core/apply
            core.clj:2468 clojure.core/partial[fn]
          RestFn.java:408 clojure.lang.RestFn.invoke
            core.clj:2559 clojure.core/map[fn]
          LazySeq.java:40 clojure.lang.LazySeq.sval
          LazySeq.java:49 clojure.lang.LazySeq.seq
              RT.java:484 clojure.lang.RT.seq
             core.clj:133 clojure.core/seq
            core.clj:2595 clojure.core/filter[fn]
          LazySeq.java:40 clojure.lang.LazySeq.sval
          LazySeq.java:56 clojure.lang.LazySeq.seq
             Cons.java:39 clojure.lang.Cons.next
          LazySeq.java:81 clojure.lang.LazySeq.next
              RT.java:598 clojure.lang.RT.next
              core.clj:64 clojure.core/next
            core.clj:2856 clojure.core/dorun
            core.clj:2871 clojure.core/doall
             eval.clj:126 lighttable.nrepl.eval/eval-clj
          RestFn.java:442 clojure.lang.RestFn.invoke
            sonar.clj:215 lighttable.nrepl.sonar/eval5355[fn]
             AFn.java:152 clojure.lang.AFn.applyToHelper
             AFn.java:144 clojure.lang.AFn.applyTo
             core.clj:624 clojure.core/apply
            core.clj:1862 clojure.core/with-bindings*
          RestFn.java:425 clojure.lang.RestFn.invoke
            sonar.clj:203 lighttable.nrepl.sonar/eval5355[fn]
         MultiFn.java:227 clojure.lang.MultiFn.invoke
              core.clj:98 lighttable.nrepl.core/queued[fn]
            core.clj:2402 clojure.core/comp[fn]
interruptible_eval.clj:138 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
              AFn.java:22 clojure.lang.AFn.run
ThreadPoolExecutor.java:1145 java.util.concurrent.ThreadPoolExecutor.runWorker
ThreadPoolExecutor.java:615 java.util.concurrent.ThreadPoolExecutor$Worker.run
          Thread.java:744 java.lang.Thread.run**
3
  • Could you describe a little more about how you started the process that is providing the repl on the server, can I assume you SSH'd in and ran leiningen? May 9, 2014 at 17:38
  • You are correct! I start a headless Ubuntu server, and then ssh Core - the server hostname. I run lein repl, specifying a host and port. Then I use those details in LightTable, paste my sample code in and... schtooops! If I set the DISPLAY variable, it just throws a similar, but different, error.
    – Dvious
    May 9, 2014 at 18:47
  • "one that opens a file chooser dialog". What exactly do you want to happen at this point on a headless server? May 11, 2014 at 10:29

2 Answers 2

1

I don't know enough about your setup to give an explanation, but I've encountered this error before, and running java/clojure with -Djava.awt.headless=true solved the problem. See here for more info.

1
  • Thanks for replying. I previously had that in my Clojure project as - :jvm_opts ["-Djava.awt.headless=true"] but, it didn't make a difference. I'll keep it in the project.clj, though.
    – Dvious
    May 9, 2014 at 18:36
0

If you want the remote lein to be able to open windows on the local system you could

ssh -X core.domain.com 
lein repl ....

This will cause any windows created by the remote server to be tunneled back over the SSH connection to your desktop. though only so long as you keep the SSH connection alive.

2
  • I have been doing that, without success.
    – Dvious
    May 10, 2014 at 12:20
  • I seem to have it working for now. I managed to make a sample program launch a OS X native dialog. To do it, I had to create the xfvb service, and set the /etc/ennvironment/DISPLAY variable to my server IP address. With Tomcat started, I launched a repl, and opened LT to the same repl. It all worked, so problem solved!
    – Dvious
    May 12, 2014 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.