This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-25
Channels
- # announcements (4)
- # babashka (3)
- # beginners (79)
- # biff (4)
- # calva (17)
- # cider (18)
- # clj-kondo (21)
- # cljdoc (45)
- # cljs-dev (14)
- # cljsrn (9)
- # clojure (90)
- # clojure-europe (86)
- # clojure-italy (3)
- # clojure-nl (3)
- # clojure-portugal (1)
- # clojure-uk (9)
- # clojurescript (20)
- # code-reviews (23)
- # conjure (14)
- # cursive (12)
- # datascript (12)
- # emacs (5)
- # events (2)
- # fulcro (13)
- # gratitude (1)
- # holy-lambda (9)
- # lambdaisland (2)
- # malli (6)
- # nbb (1)
- # nextjournal (2)
- # nrepl (30)
- # off-topic (63)
- # pathom (1)
- # portal (24)
- # reagent (5)
- # reitit (13)
- # releases (2)
- # remote-jobs (1)
- # sci (90)
- # shadow-cljs (59)
- # spacemacs (5)
- # sql (13)
- # testing (20)
- # tools-build (17)
- # xtdb (27)
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 clojure.tools.logging.impl.LoggerFactory
(log in thread). My original deps configuration was quite simple with only :extra-paths
and :extra-deps
from aliases. Any ideas?
{:clojure.main/message “Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:641).\nclojure.tools.logging.impl.LoggerFactory\n”, :clojure.main/triage {:clojure.error/class java.lang.ClassNotFoundException, :clojure.error/line 641, :clojure.error/cause “clojure.tools.logging.impl.LoggerFactory”, :clojure.error/symbol jdk.internal.loader.BuiltinClassLoader/loadClass, :clojure.error/source “BuiltinClassLoader.java”, :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 “clojure.tools.logging.impl.LoggerFactory”, :at [jdk.internal.loader.BuiltinClassLoader loadClass “BuiltinClassLoader.java” 641]}], :trace [[jdk.internal.loader.BuiltinClassLoader loadClass “BuiltinClassLoader.java” 641] [jdk.internal.loader.ClassLoaders$AppClassLoader loadClass “ClassLoaders.java” 188] [java.lang.ClassLoader loadClass “ClassLoader.java” 520] [<redacted>.backend.main$_main invokeStatic “main.clj” 107] [<redacted>.backend.main$_main invoke “main.clj” 106] [clojure.lang.AFn applyToHelper “AFn.java” 152] [clojure.lang.AFn applyTo “AFn.java” 144] [clojure.lang.Var applyTo “Var.java” 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 “RestFn.java” 137] [clojure.lang.Var applyTo “Var.java” 705] [clojure.main main “main.java” 40]], :cause “clojure.tools.logging.impl.LoggerFactory”}}
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
If that all looks fine, then I would wonder about whether you are doing aot with compile-clj
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 https://stackoverflow.com/questions/8291910/noclassdeffounderror-with-clojure-tools-logging that perhaps I should be compiling clojure.tools.logging.impl
. 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
@U02CC5T8LLU You'll need to specify those aliases when creating the basis -- see https://clojure.github.io/tools.build/clojure.tools.build.api.html#var-create-basis
(you should not need to do anything special for tools.logging
)
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)
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).
clojure.tools.reader.reader_types.Reader
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
?
:build {:deps {io.github.clojure/tools.build {: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
?
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 clojure.tools.logging.impl.LoggerFactory
is still not found.
@U02CC5T8LLU Did you resolve this? I'm facing a similar issue.