Fork me on GitHub
ossosoi loso12:04:55

Hi, I’m migrating from depstar 1.x to tools-build for building an uberjar. The uberjar resulting from tools-build gives, when running, a ClassNotFoundException for (log in thread). My original deps configuration was quite simple with only :extra-paths and :extra-deps from aliases. Any ideas?

ossosoi loso12:04:32

{:clojure.main/message “Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (\\n”, :clojure.main/triage {:clojure.error/class java.lang.ClassNotFoundException, :clojure.error/line 641, :clojure.error/cause “”, :clojure.error/symbol jdk.internal.loader.BuiltinClassLoader/loadClass, :clojure.error/source “”, :clojure.error/phase :execution}, :clojure.main/trace {:via [{:type java.lang.NoClassDefFoundError, :message “clojure/tools/logging/impl/LoggerFactory”, :at [<redacted>.backend.main$_main invokeStatic “main.clj” 107]} {:type java.lang.ClassNotFoundException, :message “”, :at [jdk.internal.loader.BuiltinClassLoader loadClass “” 641]}], :trace [[jdk.internal.loader.BuiltinClassLoader loadClass “” 641] [jdk.internal.loader.ClassLoaders$AppClassLoader loadClass “” 188] [java.lang.ClassLoader loadClass “” 520] [<redacted>.backend.main$_main invokeStatic “main.clj” 107] [<redacted>.backend.main$_main invoke “main.clj” 106] [clojure.lang.AFn applyToHelper “” 152] [clojure.lang.AFn applyTo “” 144] [clojure.lang.Var applyTo “” 705] [clojure.core$apply invokeStatic “core.clj” 667] [clojure.main$main_opt invokeStatic “main.clj” 514] [clojure.main$main_opt invoke “main.clj” 510] [clojure.main$main invokeStatic “main.clj” 664] [clojure.main$main doInvoke “main.clj” 616] [clojure.lang.RestFn applyTo “” 137] [clojure.lang.Var applyTo “” 705] [clojure.main main “” 40]], :cause “”}}

Alex Miller (Clojure team)12:04:19

Not sure there is info here to tell. Seems like the Uber jar is missing something - can you look at the jar contents to get a sense of whether it mostly contains what you expect? (Like other deps). The uberjar deps should be based on the basis, which is effectively what you would see from clj -X:deps list :user nil

👍 1
Alex Miller (Clojure team)12:04:23

If that all looks fine, then I would wonder about whether you are doing aot with compile-clj

ossosoi loso18:04:24

Thanks! An update: Most deps seem to be in the jar. clj -X:common:backend:deps list :user nil only gives the stock clojure deps (none of my deps). With depstar v2 the following works clojure -X:uberjar :jar target/os.jar :aliases '[:common :backend]' . My b/compile-clj only differs by the basis which has the aliases from the uberjar command above. I added :gen-class to my main ns definition to no avail. I read on that perhaps I should be compiling I have not figured out how to do that yet. I think I might go to check depstar’s example projects next and see how they made the jump to tools-build


(you should not need to do anything special for tools.logging)

ossosoi loso18:04:04

Does this look right?

(def basis (b/create-basis {:project "deps.edn"
                            :aliases [:common :backend]}))


I think so, yes.


(it looks like how we pass aliases to create-basis in our build.clj script at work)

ossosoi loso18:04:02

I don’t know what I did but I”m getting a different error when compiling now:

Syntax error (ClassNotFoundException) compiling at (/private/var/folders/wc/j7lkhy7n76zcgf1ccbvrv0lh0000gp/T/compile-clj6120235454022173811/compile.clj:1:1).
Among many things I cleared the class dir. And added :gen-class


Sounds like you have conflicting versions of tools.reader perhaps?


What is in your :build alias in deps.edn?

ossosoi loso18:04:26

:build {:deps {io.github.clojure/ {:git/tag “v0.8.1” :git/sha “7d40500"}} :extra-paths [“target/shadow/prod/resources” “dev-resources”] :paths [“./infra/app”] :ns-default “build”}


Also maybe look at the output of clojure -X:deps tree :aliases '[:common :backend]' for references to tools.reader?

ossosoi loso18:04:35

Looks indeed like I have many versions of tools.reader as deps (of deps…). I’ll have to return to this tomorrow. Thanks for the help! EDIT: Looks like is still not found.


@U02CC5T8LLU Did you resolve this? I'm facing a similar issue.