Giter VIP home page Giter VIP logo

Comments (18)

vlaaad avatar vlaaad commented on June 5, 2024 1

@victorb I created #17 for this discussion, it's a separate issue.

@ahungry does lein work for you if you create project with different name (not cljfx)?

from cljfx.

vlaaad avatar vlaaad commented on June 5, 2024

Here is a minimal lein example I tried:
project.clj:

(defproject lein-cljfx-test "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [cljfx "1.2.9"]]
  :main lein-cljfx-test.core)

src/lein_cljfx_test/core.clj:

(ns lein-cljfx-test.core
  (:require [cljfx.api :as fx])
  (:gen-class)
  (:import [javafx.application Platform]))

(defn -main [& args]
  (Platform/setImplicitExit true)
  (fx/on-fx-thread
    (fx/create-component
      {:fx/type :stage
       :showing true
       :scene {:fx/type :scene
               :root {:fx/type :v-box
                      :children [{:fx/type :label
                                  :text "Hello from lein!"}]}}})))

Run from command line:

lein run

After running this command a window appeared with "Hello from lein!" text, can you try it and check if it works?

from cljfx.

ahungry avatar ahungry commented on June 5, 2024

Caused by: java.io.FileNotFoundException: Could not locate cljfx/api__init.class, cljfx/api.clj or cljfx/api.cljc on classpath.

Same error.

java -version
openjdk version "11.0.3" 2019-04-16

This is consistent on both Ubuntu 18.04 and Arch Linux (latest updated).

from cljfx.

vlaaad avatar vlaaad commented on June 5, 2024

Can you post full stack trace?

from cljfx.

vlaaad avatar vlaaad commented on June 5, 2024

I use Ubuntu 19.04, had Ubuntu 18.04 before and had no such problems, hope there is something more in the stack trace. Also I'd try to print java and clojure versions from running program (without requiring cljfx.api) — I've seen before lein using different java version when running program because of 1.8 being on the environment

from cljfx.

seancorfield avatar seancorfield commented on June 5, 2024

What version of lein are you using? What's in your ~/.lein/profiles.clj file? (often things in there interfere with running some projects)

from cljfx.

ahungry avatar ahungry commented on June 5, 2024
lein --version
Leiningen 2.8.3 on Java 11.0.3 OpenJDK 64-Bit Server VM

Stacktrace:

Exception in thread "main" Syntax error compiling at (cljfx/core.clj:1:1).                                                                                                                                                             [20/144]
        at clojure.lang.Compiler.load(Compiler.java:7647)         
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:463)             
        at clojure.lang.RT.load(RT.java:428)                 
        at clojure.core$load$fn__6824.invoke(core.clj:6126)   
        at clojure.core$load.invokeStatic(core.clj:6125)   
        at clojure.core$load.doInvoke(core.clj:6109) 
        at clojure.lang.RestFn.invoke(RestFn.java:408)       
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)                                                                  
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)   
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at user$eval140$fn__144.invoke(form-init5339610884014396360.clj:1)
        at user$eval140.invokeStatic(form-init5339610884014396360.clj:1)
        at user$eval140.invoke(form-init5339610884014396360.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:7176)   
        at clojure.lang.Compiler.eval(Compiler.java:7166)
        at clojure.lang.Compiler.load(Compiler.java:7635)
        at clojure.lang.Compiler.loadFile(Compiler.java:7573)
        at clojure.main$load_script.invokeStatic(main.clj:452)
        at clojure.main$init_opt.invokeStatic(main.clj:454)
        at clojure.main$init_opt.invoke(main.clj:454)  
        at clojure.main$initialize.invokeStatic(main.clj:485)
        at clojure.main$null_opt.invokeStatic(main.clj:519)
        at clojure.main$null_opt.invoke(main.clj:516)  
        at clojure.main$main.invokeStatic(main.clj:598)
        at clojure.main$main.doInvoke(main.clj:561)                        
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:37)               
Caused by: java.io.FileNotFoundException: Could not locate cljfx/api__init.class, cljfx/api.clj or cljfx/api.cljc on classpath.
        at clojure.lang.RT.load(RT.java:466)             
        at clojure.lang.RT.load(RT.java:428)
        at clojure.core$load$fn__6824.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at cljfx.core$eval157$loading__6706__auto____158.invoke(core.clj:1)
        at cljfx.core$eval157.invokeStatic(core.clj:1)
        at cljfx.core$eval157.invoke(core.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:7176)
        at clojure.lang.Compiler.eval(Compiler.java:7165)
        at clojure.lang.Compiler.load(Compiler.java:7635)
        ... 40 more

from cljfx.

ahungry avatar ahungry commented on June 5, 2024
java -version                                                                                                                                                                                                 
openjdk version "11.0.3" 2019-04-16                                                                                                                                                                                                           
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)                                                                                                                                                                           
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)

Nothing in lein profiles directory.

Maybe I'll find time to make a minimal sample Dockerfile that can reproduce this issue.

from cljfx.

vlaaad avatar vlaaad commented on June 5, 2024

Can you show me an output of lein run if you change src/lein_cljfx_test/core.clj like that?

(ns lein-cljfx-test.core)

(defn -main [& args]
  (println *clojure-version*)
  (println (System/getProperty "java.vm.version")))

from cljfx.

ahungry avatar ahungry commented on June 5, 2024
{:major 1, :minor 10, :incremental 0, :qualifier nil}
11.0.3+7-Ubuntu-1ubuntu218.04.1

from cljfx.

vlaaad avatar vlaaad commented on June 5, 2024

Well, requirements are met.. Can you try effectively the same snippet using JavaFX only to see if it's related to cljfx or javafx?
To do it, modify project.clj to be like that:

(defproject lein-cljfx-test "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [org.openjfx/javafx-base "12"]
                 [org.openjfx/javafx-graphics "12"]
                 [org.openjfx/javafx-controls "12"]]
  :main lein-cljfx-test.core)

And src/lein_cljfx_test/core.clj to be like that:

(ns lein-cljfx-test.core
  (:import [javafx.application Platform]
           [javafx.scene Scene]
           [javafx.stage Stage]
           [javafx.scene.control Label]
           [javafx.scene.layout VBox]))

(defn -main [& args]
  (Platform/startup #(prn :started))
  (Platform/runLater
    #(doto (Stage.)
       (.setScene (Scene.
                    (doto (VBox.)
                      (-> .getChildren (.add (Label. "Hello from lein"))))))
       (.show))))

from cljfx.

ahungry avatar ahungry commented on June 5, 2024

That worked with direct inclusion, I received the GUI printing Hello from lein as expected.

from cljfx.

vlaaad avatar vlaaad commented on June 5, 2024

Hmm, not sure what to do next... I also noticed that exception has (cljfx/core.clj:1:1) in it, but cljfx does not have a cljfx/core.clj file, is it a file you created yourself and required cljfx.api from it? Maybe lein is confused and expects to find cljfx/api.clj in your source directory? Or it can't properly add cljfx to your classpath for some reason and lein clean can help? What is lein deps :tree output for you when cljfx is present in :dependencies?

from cljfx.

ahungry avatar ahungry commented on June 5, 2024

Yea sorry, my entry point file for this project was created with lein new app cljfx vs lein new app lein-cljfx-test, so thats essentially referencing the lein-cljfx-test core from your given instructions.

At least deps.edn works well with this 😆 gives me a good reason to get aboard the deps train.

from cljfx.

vlaaad avatar vlaaad commented on June 5, 2024

Can you try with differently named lein project? It might be that lein thinks that cljfx is your project, not a dependency, because they have the same name.

from cljfx.

victorb avatar victorb commented on June 5, 2024

@vlaaad another thing. Seems lein uberjar never finishes it's build, unsure of why. Seems there is maybe some issue with when clojure runs the classes static initializer and something gets started, which never gets closed afterwards.

Copying the example you made above:

(ns lein-cljfx-test.core
  (:require [cljfx.api :as fx])
  (:gen-class)
  (:import [javafx.application Platform]))

(defn -main [& args]
  (Platform/setImplicitExit true)
  (fx/on-fx-thread
    (fx/create-component
      {:fx/type :stage
       :showing true
       :scene {:fx/type :scene
               :root {:fx/type :v-box
                      :children [{:fx/type :label
                                  :text "Hello from lein!"}]}}})))

Runs fine with lein run (and thanks to setImplicitExit, also exits the full application when closing the javafx application)

However, running lein uberjar with that example, leads to the lein getting stuck at Compiling lein-cljfx-test.core forever (seemingly, I let it run for 20 minutes)

Running strace -f lein uberjar also confirms that it's waiting for something, but that something never happens.

Any advice on what could be happening?

(using clojure 1.10.0 + cljfx 1.2.10 with both openjdk and jdk version 11)

from cljfx.

ahungry avatar ahungry commented on June 5, 2024

@vlaaad I can confirm after a rename of the project, no more issue. Thanks for the assist and feel free to close this :)

from cljfx.

vlaaad avatar vlaaad commented on June 5, 2024

Glad that it worked for you!

from cljfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.