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)))
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..)
@iagwanderson you can try skipping javafx initialization
https://github.com/cljfx/cljfx#aot-compilation-is-complicated
While that's not a guarantee, it helps in most cases
@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
.
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)
when I compiled without AOT, I got an error from cljfx.coerce
what was the error?
Let me reproduce and send the error message here...
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
1. Caused by java.lang.ClassNotFoundException
javafx.event.EventHandler
this means you donโt have JavaFX on your classpath
java 8?
java 11
hmm
let me try to explicitly add the javafx dependencies in the project
have you changed the jdk from java 8 to java 11?
I have been using java 11 for a long time now.
ah, cool
looking at the REBL page, they explicitly add javafx dependencies on java 11 projects
maybe I need to do the same
nope, cljfx adds dependencies on javafx by itself
uhmmm.. makes sense
I would say some context is missingโฆ
have you built a cljfx app as uberjar?
yes
is the OS used when the uberjar was built the same as OS where you use that uberjar?
yes, Linux arch 5.4.68-1-lts
hmm, I donโt know what else to ask ๐
hehe.. this is the link to my project https://github.com/wandersoncferreira/replr
pet project to explore some ideas that I was curious at (cljfx, nrepl integration)
hey @vlaaad, I doubled checked the version of the jdk used by the project that I am trying to import the cljfx app into
and it was java 8 there ๐ my bad. Now I synced both in java 11
np ๐
"worked", but not. hehe different error ๐
which means progress
๐
by the way, cljfx supports java 8 as well
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
my app is running inside a docker container too (if that is relevant here)
but java 8 support relies on JavaFX being a part of a JDK (it was there before)
I would guess docker containers are headless?
yes, true
not sure now if I was able to run rebl inside my container too
why would you want to run UI app in a docker container?
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.
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.
People go completely overboard with docker