cljfx

https://github.com/cljfx/cljfx
bartuka 2020-09-30T03:27:10.017100Z

to provide more info, I tried to create a custom task in leiningen as follows:

(ns leiningen.ujar
  (:require leiningen.uberjar
            leiningen.core.eval))

(defn ujar [project]
  (leiningen.uberjar/uberjar project)
  (leiningen.core.eval/eval-in-project project `(javafx.application.Platform/exit)))

bartuka 2020-09-30T03:29:05.019300Z

the problem is that uberjar never returns, it hangs waiting for the thread to be closed. I looked at the last file compiled by uberjar and placed the exit code at the end of the namespace and it worked (finished the build)... but, does not look like a good approach. (also, I think the runtime will be compromised in this way... didn't test yet..)

vlaaad 2020-09-30T05:18:40.019500Z

@iagwanderson you can try skipping javafx initialization

vlaaad 2020-09-30T05:18:58.019800Z

While that's not a guarantee, it helps in most cases

seancorfield 2020-09-30T06:03:38.022400Z

@iagwanderson Why do you need to do AOT? You can build an uberjar without AOT and still run the resultant JAR, albeit with a slightly less compact command. Another alternative is to write a stub -main ns that uses runtime require/`resolve` (or requiring-resolve if you're on 1.10) to invoke your actual program main. Then AOT of that ns will not transitively try to compile the rest of your code but you can still run the JAR with java -jar.

bartuka 2020-09-30T12:04:01.024100Z

thanks for the comments. Let me try to explain more about what I am doing. I developed a cljfx page (using list-view, label, button basically) and I am trying require the namespace of this project on another project. (similar to a REBL)

bartuka 2020-09-30T12:04:19.024500Z

when I compiled without AOT, I got an error from cljfx.coerce

vlaaad 2020-09-30T12:04:39.025100Z

what was the error?

bartuka 2020-09-30T12:04:43.025300Z

Let me reproduce and send the error message here...

bartuka 2020-09-30T12:08:22.026100Z

2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling cljfx/coerce.clj at (1:1)
   #:clojure.error{:phase :compile-syntax-check,
                   :line 1,
                   :column 1,
                   :source "cljfx/coerce.clj"}
             Compiler.java: 7648  clojure.lang.Compiler/load
                   RT.java:  381  clojure.lang.RT/loadResourceScript
                   RT.java:  372  clojure.lang.RT/loadResourceScript
                   RT.java:  459  clojure.lang.RT/load
                   RT.java:  424  clojure.lang.RT/load
                  core.clj: 6126  clojure.core/load/fn
                  core.clj: 6125  clojure.core/load
                  core.clj: 6109  clojure.core/load
               RestFn.java:  408  clojure.lang.RestFn/invoke
                  core.clj: 5908  clojure.core/load-one
                  core.clj: 5903  clojure.core/load-one
                  core.clj: 5948  clojure.core/load-lib/fn
                  core.clj: 5947  clojure.core/load-lib
                  core.clj: 5928  clojure.core/load-lib
               RestFn.java:  142  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 5985  clojure.core/load-libs
                  core.clj: 5969  clojure.core/load-libs
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 6007  clojure.core/require
                  core.clj: 6007  clojure.core/require
               RestFn.java:  482  clojure.lang.RestFn/invoke
             lifecycle.clj:    1  cljfx.lifecycle/eval46123/loading--auto--
             lifecycle.clj:    1  cljfx.lifecycle/eval46123
             lifecycle.clj:    1  cljfx.lifecycle/eval46123
             Compiler.java: 7177  clojure.lang.Compiler/eval
             Compiler.java: 7166  clojure.lang.Compiler/eval
             Compiler.java: 7636  clojure.lang.Compiler/load
                   RT.java:  381  clojure.lang.RT/loadResourceScript
                   RT.java:  372  clojure.lang.RT/loadResourceScript
                   RT.java:  459  clojure.lang.RT/load
                   RT.java:  424  clojure.lang.RT/load
                  core.clj: 6126  clojure.core/load/fn
                  core.clj: 6125  clojure.core/load
                  core.clj: 6109  clojure.core/load
               RestFn.java:  408  clojure.lang.RestFn/invoke
                  core.clj: 5908  clojure.core/load-one
                  core.clj: 5903  clojure.core/load-one
                  core.clj: 5948  clojure.core/load-lib/fn
                  core.clj: 5947  clojure.core/load-lib
                  core.clj: 5928  clojure.core/load-lib
               RestFn.java:  142  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 5985  clojure.core/load-libs
                  core.clj: 5969  clojure.core/load-libs
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 6007  clojure.core/require
                  core.clj: 6007  clojure.core/require
               RestFn.java:  436  clojure.lang.RestFn/invoke
              defaults.clj:    1  cljfx.defaults/eval45756/loading--auto--
              defaults.clj:    1  cljfx.defaults/eval45756
              defaults.clj:    1  cljfx.defaults/eval45756
             Compiler.java: 7177  clojure.lang.Compiler/eval
             Compiler.java: 7166  clojure.lang.Compiler/eval
             Compiler.java: 7636  clojure.lang.Compiler/load
                   RT.java:  381  clojure.lang.RT/loadResourceScript
                   RT.java:  372  clojure.lang.RT/loadResourceScript
                   RT.java:  459  clojure.lang.RT/load
                   RT.java:  424  clojure.lang.RT/load
                  core.clj: 6126  clojure.core/load/fn
                  core.clj: 6125  clojure.core/load
                  core.clj: 6109  clojure.core/load
               RestFn.java:  408  clojure.lang.RestFn/invoke
                  core.clj: 5908  clojure.core/load-one
                  core.clj: 5903  clojure.core/load-one
                  core.clj: 5948  clojure.core/load-lib/fn
                  core.clj: 5947  clojure.core/load-lib
                  core.clj: 5928  clojure.core/load-lib
               RestFn.java:  142  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 5985  clojure.core/load-libs
                  core.clj: 5969  clojure.core/load-libs
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 6007  clojure.core/require
                  core.clj: 6007  clojure.core/require
               RestFn.java:  619  clojure.lang.RestFn/invoke
                   api.clj:    1  cljfx.api/eval45546/loading--auto--
                   api.clj:    1  cljfx.api/eval45546
                   api.clj:    1  cljfx.api/eval45546
             Compiler.java: 7177  clojure.lang.Compiler/eval
             Compiler.java: 7166  clojure.lang.Compiler/eval
             Compiler.java: 7636  clojure.lang.Compiler/load
                   RT.java:  381  clojure.lang.RT/loadResourceScript
                   RT.java:  372  clojure.lang.RT/loadResourceScript
                   RT.java:  459  clojure.lang.RT/load
                   RT.java:  424  clojure.lang.RT/load
                  core.clj: 6126  clojure.core/load/fn
                  core.clj: 6125  clojure.core/load
                  core.clj: 6109  clojure.core/load
               RestFn.java:  408  clojure.lang.RestFn/invoke
                  core.clj: 5908  clojure.core/load-one
                  core.clj: 5903  clojure.core/load-one
                  core.clj: 5948  clojure.core/load-lib/fn
                  core.clj: 5947  clojure.core/load-lib
                  core.clj: 5928  clojure.core/load-lib
               RestFn.java:  142  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 5985  clojure.core/load-libs
                  core.clj: 5969  clojure.core/load-libs
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 6007  clojure.core/require
                  core.clj: 6007  clojure.core/require
               RestFn.java:  482  clojure.lang.RestFn/invoke
                    ui.clj:    1  replr.ui/eval45538/loading--auto--
                    ui.clj:    1  replr.ui/eval45538
                    ui.clj:    1  replr.ui/eval45538
             Compiler.java: 7177  clojure.lang.Compiler/eval
             Compiler.java: 7166  clojure.lang.Compiler/eval
             Compiler.java: 7636  clojure.lang.Compiler/load
                   RT.java:  381  clojure.lang.RT/loadResourceScript
                   RT.java:  372  clojure.lang.RT/loadResourceScript
                   RT.java:  459  clojure.lang.RT/load
                   RT.java:  424  clojure.lang.RT/load
                  core.clj: 6126  clojure.core/load/fn
                  core.clj: 6125  clojure.core/load
                  core.clj: 6109  clojure.core/load
               RestFn.java:  408  clojure.lang.RestFn/invoke
                  core.clj: 5908  clojure.core/load-one
                  core.clj: 5903  clojure.core/load-one
                  core.clj: 5948  clojure.core/load-lib/fn
                  core.clj: 5947  clojure.core/load-lib
                  core.clj: 5928  clojure.core/load-lib
               RestFn.java:  142  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 5985  clojure.core/load-libs
                  core.clj: 5969  clojure.core/load-libs
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 6007  clojure.core/require
                  core.clj: 6007  clojure.core/require
               RestFn.java:  408  clojure.lang.RestFn/invoke
                      REPL:   45  user/eval45534
                      REPL:   45  user/eval45534
             Compiler.java: 7177  clojure.lang.Compiler/eval
             Compiler.java: 7132  clojure.lang.Compiler/eval
                  core.clj: 3214  clojure.core/eval
                  core.clj: 3210  clojure.core/eval
                  main.clj:  437  clojure.main/repl/read-eval-print/fn
                  main.clj:  437  clojure.main/repl/read-eval-print
                  main.clj:  458  clojure.main/repl/fn
                  main.clj:  458  clojure.main/repl
                  main.clj:  368  clojure.main/repl
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  665  clojure.core/apply
                  core.clj:  660  clojure.core/apply
                regrow.clj:   18  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   79  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  142  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  171  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  170  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  748  java.lang.Thread/run

1. Caused by java.lang.ClassNotFoundException
   javafx.event.EventHandler

vlaaad 2020-09-30T12:08:48.026700Z

1. Caused by java.lang.ClassNotFoundException
   javafx.event.EventHandler

vlaaad 2020-09-30T12:09:01.027100Z

this means you donโ€™t have JavaFX on your classpath

vlaaad 2020-09-30T12:09:13.027500Z

java 8?

bartuka 2020-09-30T12:09:19.027700Z

java 11

vlaaad 2020-09-30T12:10:02.028200Z

hmm

bartuka 2020-09-30T12:10:12.028500Z

let me try to explicitly add the javafx dependencies in the project

vlaaad 2020-09-30T12:10:40.029200Z

have you changed the jdk from java 8 to java 11?

bartuka 2020-09-30T12:11:20.029900Z

I have been using java 11 for a long time now.

vlaaad 2020-09-30T12:11:27.030100Z

ah, cool

bartuka 2020-09-30T12:11:52.030700Z

looking at the REBL page, they explicitly add javafx dependencies on java 11 projects

bartuka 2020-09-30T12:11:56.031Z

maybe I need to do the same

vlaaad 2020-09-30T12:12:17.031500Z

nope, cljfx adds dependencies on javafx by itself

bartuka 2020-09-30T12:12:48.032100Z

uhmmm.. makes sense

vlaaad 2020-09-30T12:13:12.032500Z

I would say some context is missingโ€ฆ

vlaaad 2020-09-30T12:13:22.032800Z

have you built a cljfx app as uberjar?

bartuka 2020-09-30T12:13:36.033Z

yes

vlaaad 2020-09-30T12:14:14.033600Z

is the OS used when the uberjar was built the same as OS where you use that uberjar?

bartuka 2020-09-30T12:14:35.033900Z

yes, Linux arch 5.4.68-1-lts

vlaaad 2020-09-30T12:15:34.034200Z

hmm, I donโ€™t know what else to ask ๐Ÿ™‚

bartuka 2020-09-30T12:17:21.034500Z

hehe.. this is the link to my project https://github.com/wandersoncferreira/replr

bartuka 2020-09-30T12:17:46.035200Z

pet project to explore some ideas that I was curious at (cljfx, nrepl integration)

bartuka 2020-09-30T12:27:14.036800Z

hey @vlaaad, I doubled checked the version of the jdk used by the project that I am trying to import the cljfx app into

bartuka 2020-09-30T12:27:30.037200Z

and it was java 8 there ๐Ÿ˜ž my bad. Now I synced both in java 11

vlaaad 2020-09-30T12:27:37.037500Z

np ๐Ÿ™‚

bartuka 2020-09-30T12:27:39.037700Z

"worked", but not. hehe different error ๐Ÿ˜ƒ

bartuka 2020-09-30T12:27:44.038Z

which means progress

bartuka 2020-09-30T12:27:46.038200Z

๐Ÿ™‚

vlaaad 2020-09-30T12:27:51.038400Z

by the way, cljfx supports java 8 as well

bartuka 2020-09-30T12:27:56.038700Z

Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /root/.openjfx/cache/14/libprism_es2.so: libX11.so.6: cannot open shared object file: No such file or directory
java.lang.UnsatisfiedLinkError: /root/.openjfx/cache/14/libprism_es2.so: libX11.so.6: cannot open shared object file: No such file or directory

bartuka 2020-09-30T12:28:58.039900Z

my app is running inside a docker container too (if that is relevant here)

vlaaad 2020-09-30T12:29:03.040100Z

but java 8 support relies on JavaFX being a part of a JDK (it was there before)

vlaaad 2020-09-30T12:29:16.040400Z

I would guess docker containers are headless?

bartuka 2020-09-30T12:30:05.040700Z

yes, true

bartuka 2020-09-30T12:30:48.041100Z

not sure now if I was able to run rebl inside my container too

vlaaad 2020-09-30T12:31:30.041400Z

why would you want to run UI app in a docker container?

bartuka 2020-09-30T12:33:02.042700Z

actually I am thinking in the current setup my company uses. Every project has a docker-compose attached to it and I would like this UI to be open while they are developing.

bartuka 2020-09-30T12:37:06.043700Z

anyway... thanks so much @vlaaad... it is working fine. Interesting to see the amount of fns a relative small app in my company have. haha.

๐Ÿ˜บ 1
zilti 2020-09-30T20:18:35.044900Z

People go completely overboard with docker

๐Ÿ”ฅ 1