Open ghost opened 9 years ago
I also encountered this issue. According to this discussion (https://groups.google.com/forum/m/#!topic/leiningen/s9CBKp832YE), initializations are executed while AOT. I'm not sure about that, I think it's a problem of fx-clj. Maybe some patches will be needed.
Can anyone post a stack trace? On Wed, Sep 16, 2015 at 3:56 AM KPCCoiL notifications@github.com wrote:
I also encountered this issue. According to this discussion ( https://groups.google.com/forum/m/#!topic/leiningen/s9CBKp832YE), initializations are executed while AOT. I'm not sure about that, I think it's a problem of fx-clj. Maybe some patches will be needed.
— Reply to this email directly or view it on GitHub https://github.com/aaronc/fx-clj/issues/5#issuecomment-140660040.
I don't know how to display the stack trace, but I could cause the problem with this tiny project:
project.clj:
(defproject fx-clj-test "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0-alpha2"]
[fx-clj "0.2.0-alpha1"]]
:main ^:skip-aot fx-clj-test.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
src/fx_clj_test/core.clj:
(ns fx-clj-test.core
(:require [fx-clj.core :as fx])
(:gen-class))
(defn make-view []
(fx/button "Hello!"))
(defn -main [& args]
(fx/sandbox #'make-view))
When I executed lein uberjar
in this project, "Compiling fx-clj-test.core" appeared and it freezed. In other hand, lein run
works fine.
I was able to create an uberjar but that was a while ago and it took some tweaking. My issue was related to a dependency that was causing problems, but I've since replaced that dependency. Unfortunately, I haven't been working with this code base for a while and don't really have a lot of time right now. Maybe someone else can provide some insight?
On Wed, Sep 16, 2015 at 10:23 AM, KPCCoiL notifications@github.com wrote:
I don't know how to display the stack trace, but I could cause the problem with this tiny project:
project.clj:
(defproject fx-clj-test "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0-alpha2"] [fx-clj "0.2.0-alpha1"]] :main ^:skip-aot fx-clj-test.core :target-path "target/%s" :profiles {:uberjar {:aot :all}})
src/fx_clj_test/core.clj:
(ns fx-clj-test.core (:require [fx-clj.core :as fx]) (:gen-class))
(defn -main [& args](fx/sandbox #'make-view))
When I executed lein uberjar in this project, "Compiling fx-clj-test.core" appeared and it freezed. In other hand, lein run works fine.
— Reply to this email directly or view it on GitHub https://github.com/aaronc/fx-clj/issues/5#issuecomment-140756423.
For me the line https://github.com/aaronc/fx-clj/blob/master/src/fx_clj/impl/bootstrap.clj#L4 prevents AOT, I've commented it out, called it in a fn during app startup and everything works.
might (ns ^:no-doc ^:skip-aot fx-clj.impl.bootstrap)
work ?
I have hit this problem. The ^:skip-aot did not solve the compilation hang. Removing the line entirely made the compile succeed. But then adding it into the main application made the compile hang again in the main application. Eventually I got the compile working by moving (javafx.embed.swing.JFXPanel.) into the actual mainline code. But then there is a different problem. lein run works. And lein uberjar compiles. But running the jar file with java command line doesn't work giving: java.lang.IllegalStateException: Toolkit not initialized
You need to call (javafx.embed.swing.JFXPanel.) before you use javafx. You can see a working example here: https://github.com/QAston/URDMI/blob/master/src/urdmi/gui_util.clj (see init-toolkit fn)
I just remembered that some controls may have static initializers that cause this error. In that case you need to call the static initializer later (lookup the class dynamically instead of refering to it statically from clojure).
I did call (javafx.embed.swing.JFXPanel.). Does your working example uberjar? To reiterate again:
I have given up on this approach and am now building my JavaFX app by directly extending the JavaFX Application classes via gen-class, as you would build it in Java. When I do this it all works, including the uberjar running under java -jar.
This is an example of a launcher class that works in AOT and is written in clojure https://github.com/QAston/URDMI/blob/master/src/urdmi/launcher.clj
Anyone else has problems with uberjar and compile? It just won't complete. I have to use a Runner class as a workaround and run my clojure code without AOT which results in long startup times when I run the jar file :(.