Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect to X11 window server using ':0' as the value of the DISPLAY variable. #16

Open
cpgj opened this issue Jan 21, 2023 · 6 comments

Comments

@cpgj
Copy link

cpgj commented Jan 21, 2023

Hello,

Cool project! I'm just starting to check it out, but came across a nasty issue in my setup. May not even be related to excel-clj, but I've played around with other packages and this is the first time I've seen it. If you know that this is misplaced and know where I should put it to prevent other newbs like me from banging their head against the wall like I did, I'm all ears.

I tried the Tables example and got a Java error as summarized in the issue title and in more detail below. I "fixed" it by doing "xhost +local:" from the command line as suggested in this link, and I have a couple of theories about what that means, but really I'm just a monkey miming in a mirror here.

So this Github issue boils down to, is this an issue with dependencies related to excel-clj, and if so, should there be a note in the documentation to warn new users, or should that note go elsewhere (and if so, where)? If the latter, I'm happy to repost in the appropriate location.

Thanks for any guidance!

I'm using:

  • Practicalli Spacemacs on Manjaro Linux 22.0.0 (Gnome desktop, which uses Wayland windowing system)
  • Leiningen 2.9.10 on Java 17.0.5 OpenJDK 64-Bit Server VM
  • Clojure CLI version 1.11.1.1149

From a fresh "lein new app v2", my project.clj, core.clj, and the error message follow.

project.clj:

(defproject v2 "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url "https://www.eclipse.org/legal/epl-2.0/"}
  :dependencies [[org.clojure/clojure "1.11.1"]
                 [org.clojars.mjdowney/excel-clj "2.1.0"]]
  :main ^:skip-aot v2.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all
                       :jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})

core.clj:

(ns v2.core
  (:require [excel-clj.core :as excel])
  (:gen-class))

(def table-data
  [{"Date" #inst"2018-01-01" "% Return" 0.05M "USD" 1500.5005M}
   {"Date" #inst"2018-02-01" "% Return" 0.04M "USD" 1300.20M}
   {"Date" #inst"2018-03-01" "% Return" 0.07M "USD" 2100.66666666M}])

(let [;; A workbook is any [key value] seq of [sheet-name, sheet-grid].
          ;; Convert the table to a grid with the table-grid function.
      workbook {"My Generated Sheet" (excel/table-grid table-data)}]
  (excel/write! workbook "resources/excel-clj-test.xlsx"))

Error message:

v2.core> (let [;; A workbook is any [key value] seq of [sheet-name, sheet-grid].
               ;; Convert the table to a grid with the table-grid function.
               workbook {"My Generated Sheet" (excel/table-grid table-data)}]
           (excel/write! workbook "resources/excel-clj-test.xlsx"))
Execution error (AWTError) at sun.awt.X11GraphicsEnvironment/initDisplay (X11GraphicsEnvironment.java:-2).
Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
ERROR: Unhandled REPL handler exception processing message {:op stacktrace, :nrepl.middleware.print/stream? 1, :nrepl.middleware.print/print cider.nrepl.pprint/puget-pprint, :nrepl.middleware.print/quota 1048576, :nrepl.middleware.print/buffer-size 4096, :nrepl.middleware.print/options {:width 80}, :session 797900c2-0e71-4496-acf1-9bcf7e88a4a3, :id 62}
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at clojure.core$deref_future.invokeStatic(core.clj:2317)
	at clojure.core$future_call$reify__8544.deref(core.clj:7041)
	at clojure.core$deref.invokeStatic(core.clj:2337)
	at clojure.core$pmap$step__8557$fn__8561.invoke(core.clj:7092)
	at clojure.lang.LazySeq.sval(LazySeq.java:42)
	at clojure.lang.LazySeq.seq(LazySeq.java:51)
	at clojure.lang.LazySeq.first(LazySeq.java:73)
	at clojure.lang.RT.first(RT.java:692)
	at clojure.core$first__5449.invokeStatic(core.clj:55)
	at clojure.core$first__5449.invoke(core.clj:55)
	at cider.nrepl.middleware.stacktrace$flag_duplicates.invokeStatic(stacktrace.clj:198)
	at cider.nrepl.middleware.stacktrace$flag_duplicates.invoke(stacktrace.clj:194)
	at cider.nrepl.middleware.stacktrace$analyze_stacktrace.invokeStatic(stacktrace.clj:219)
	at cider.nrepl.middleware.stacktrace$analyze_stacktrace.invoke(stacktrace.clj:213)
	at cider.nrepl.middleware.stacktrace$analyze_cause.invokeStatic(stacktrace.clj:323)
	at cider.nrepl.middleware.stacktrace$analyze_cause.invoke(stacktrace.clj:314)
	at cider.nrepl.middleware.stacktrace$analyze_causes$fn__10531.invoke(stacktrace.clj:348)
	at clojure.core$map$fn__5931$fn__5932.invoke(core.clj:2759)
	at clojure.core$take_while$fn__5982$fn__5983.invoke(core.clj:2918)
	at clojure.lang.Iterate.reduce(Iterate.java:81)
	at clojure.core$transduce.invokeStatic(core.clj:6946)
	at clojure.core$into.invokeStatic(core.clj:6962)
	at clojure.core$into.invoke(core.clj:6950)
	at cider.nrepl.middleware.stacktrace$analyze_causes.invokeStatic(stacktrace.clj:347)
	at cider.nrepl.middleware.stacktrace$analyze_causes.invoke(stacktrace.clj:339)
	at cider.nrepl.middleware.stacktrace$handle_stacktrace.invokeStatic(stacktrace.clj:356)
	at cider.nrepl.middleware.stacktrace$handle_stacktrace.invoke(stacktrace.clj:353)
	at clojure.lang.Var.invoke(Var.java:388)
	at cider.nrepl$wrap_stacktrace$fn__6878.invoke(nrepl.clj:432)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at nrepl.middleware.interruptible_eval$interruptible_eval$fn__5543.invoke(interruptible_eval.clj:154)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_inspect$fn__6814.invoke(nrepl.clj:227)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_out$fn__6838.invoke(nrepl.clj:334)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_clojuredocs$fn__6936.invoke(nrepl.clj:529)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_complete$fn__6770.invoke(nrepl.clj:143)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_undef$fn__6910.invoke(nrepl.clj:493)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_info$fn__6804.invoke(nrepl.clj:208)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_debug$fn__6780.invoke(nrepl.clj:163)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_xref$fn__6928.invoke(nrepl.clj:514)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at v2.core$eval7016$fn__7017$fn__7019.invoke(form-init6770048005804239773.clj:1)
	at cider.nrepl$wrap_apropos$fn__6754.invoke(nrepl.clj:129)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at nrepl.middleware.session$add_stdin$fn__5661.invoke(session.clj:379)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_refresh$fn__6854.invoke(nrepl.clj:380)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_resource$fn__6862.invoke(nrepl.clj:406)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_enlighten$fn__6788.invoke(nrepl.clj:190)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_test$fn__6886.invoke(nrepl.clj:442)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_classpath$fn__6762.invoke(nrepl.clj:137)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at nrepl.middleware.load_file$wrap_load_file$fn__6085.invoke(load_file.clj:81)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at nrepl.middleware.caught$wrap_caught$fn__5476.invoke(caught.clj:97)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_tracker$fn__6902.invoke(nrepl.clj:482)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at nrepl.middleware.sideloader$wrap_sideloader$fn__6166.invoke(sideloader.clj:108)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_spec$fn__6870.invoke(nrepl.clj:416)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at nrepl.middleware.dynamic_loader$wrap_dynamic_loader$fn__5729.invoke(dynamic_loader.clj:98)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_ns$fn__6830.invoke(nrepl.clj:300)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at cider.nrepl$wrap_content_type$fn__6738.invoke(nrepl.clj:107)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at nrepl.middleware.session$session$fn__5646.invoke(session.clj:325)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at nrepl.middleware.print$wrap_print$fn__5443.invoke(print.clj:234)
	at nrepl.middleware$wrap_conj_descriptor$fn__5207.invoke(middleware.clj:16)
	at nrepl.server$default_handler$fn__6214.invoke(server.clj:141)
	at nrepl.server$handle_STAR_.invokeStatic(server.clj:24)
	at nrepl.server$handle_STAR_.invoke(server.clj:21)
	at nrepl.server$handle$fn__6182.invoke(server.clj:41)
	at clojure.core$binding_conveyor_fn$fn__5823.invoke(core.clj:2047)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at clojure.lang.RT.classForName(RT.java:2209)
	at clojure.lang.RT.classForName(RT.java:2218)
	at clojure.lang.Compiler.maybeResolveIn(Compiler.java:7455)
	at clojure.core$ns_resolve.invokeStatic(core.clj:4371)
	at clojure.core$ns_resolve.invokeStatic(core.clj:4360)
	at clojure.core$ns_resolve.invoke(core.clj:4360)
	at cider.nrepl.inlined_deps.orchard.v0v10v0.orchard.java$resolve_class$fn__10018.invoke(java.clj:301)
	at cider.nrepl.inlined_deps.orchard.v0v10v0.orchard.java$resolve_class.invokeStatic(java.clj:301)
	at cider.nrepl.inlined_deps.orchard.v0v10v0.orchard.java$resolve_class.invoke(java.clj:295)
	at cider.nrepl.inlined_deps.orchard.v0v10v0.orchard.java$resolve_symbol.invokeStatic(java.clj:335)
	at cider.nrepl.inlined_deps.orchard.v0v10v0.orchard.java$resolve_symbol.invoke(java.clj:321)
	at cider.nrepl.middleware.stacktrace$analyze_fn.invokeStatic(stacktrace.clj:82)
	at cider.nrepl.middleware.stacktrace$analyze_fn.invoke(stacktrace.clj:61)
	at clojure.core$comp$fn__5876.invoke(core.clj:2586)
	at clojure.core$comp$fn__5876.invoke(core.clj:2586)
	at clojure.core$comp$fn__5876.invoke(core.clj:2586)
	at cider.nrepl.middleware.stacktrace$analyze_frame.invokeStatic(stacktrace.clj:211)
	at cider.nrepl.middleware.stacktrace$analyze_frame.invoke(stacktrace.clj:207)
	at clojure.co
@matthewdowney
Copy link
Owner

Hi there, thanks for reporting this in detail. This issue was new to me.

I think what's happening is that OpenJDK is missing some of the classes that Apache POI needs.

Does apt install fontconfig libfreetype61 get rid of this issue? If so, please let me know and I'll definitely add this front and center to the README.

Thanks!

Footnotes

  1. https://stackoverflow.com/questions/49150928/how-do-i-fix-the-noclassdeffounderror-in-java-apache-poi-project

@cpgj
Copy link
Author

cpgj commented Jan 23, 2023

My system had the Manjaro packages below since before I installed excel-clj. They look fine to me but I don't know the details.

Happy to investigate or experiment more - I'd do it myself without prompting but I don't know what would be useful.

fontconfig2

freetype2

@matthewdowney
Copy link
Owner

I'm not very familiar with Manjaro, but does

pacman -Syu fontconfig
pacman -Syu libfreetype6

do anything for you?

@cpgj
Copy link
Author

cpgj commented Jan 24, 2023

  1. I couldn't find libfreetype6 using pacman - seems to me in the Arch world, the library is just called freetype2 but the Arch version does include libfreetype.so.6 (not sure if relevant). https://archlinux.org/packages/extra/x86_64/freetype2/files/

  2. Pacman told me I already had the latest versions of fontconfig and freetype2 but I reinstalled them using pacman anyway. Feels like that should do nothing but I did it anyway. Manjaro's standard package manager (at least for the flavor that I'm using) is pamac, which is slightly different from pacman, but as far as I know the packages are the same (they're from the standard Manjaro repositories).

  3. It worked, writing a 322,000 row x 74 column dataset to .xlsx in 306 seconds.

  4. I wondered about the whole "xhost" thing, so I did "xhost -local:" and tried with 5 rows - it failed with the same old error. I did "xhost +local:" and it worked. The man page for xhost says, "The xhost program is used to add and delete host names or user names to the list allowed to make connections to the X server." Looking again at the error, "Can't connect to X11 window server ...", it feels in my un-expert opinion like xhost was causing the error.

I'm happy to consider this closed, but if you want any more follow-up/experimentation/etc., I'm happy to do it.

Thanks!

@matthewdowney
Copy link
Owner

Huh, thanks for looking into that. I think I'm still stumped about why this is happening, but I'm glad that you have found a way that works for you.

Since I don't really know what I'd put in the README, I think I'll just leave this issue open so that other people can find it and try the referenced solutions, and then if things turn out differently for someone else, hopefully they'll comment here and we can get to the bottom of it.

@cpgj
Copy link
Author

cpgj commented Jan 27, 2023

Sounds good, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants