Cannot the Project Anymore - Getting NoClassDefFoundException

Hi everyone,
Suddenly we’re getting this weird error across our multiple systems.

{:clojure.main/message
 "Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:581).\norg.joda.time.DateTime\n",
 :clojure.main/triage
 {:clojure.error/class java.lang.ClassNotFoundException,
  :clojure.error/line 581,
  :clojure.error/cause "org.joda.time.DateTime",
  :clojure.error/symbol
  jdk.internal.loader.BuiltinClassLoader/loadClass,
  :clojure.error/source "BuiltinClassLoader.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message "Syntax error macroexpanding at (core.clj:1:1).",
    :data
    {:clojure.error/phase :execution,
     :clojure.error/line 1,
     :clojure.error/column 1,
     :clojure.error/source "core.clj"},
    :at [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3711]}
   {:type java.lang.ExceptionInInitializerError,
    :at [java.lang.Class forName0 "Class.java" -2]}
   {:type java.lang.ClassNotFoundException,
    :message "org.joda.time.DateTime",
    :at
    [jdk.internal.loader.BuiltinClassLoader
     loadClass
     "BuiltinClassLoader.java"
     581]}],
  :trace
  [[jdk.internal.loader.BuiltinClassLoader
    loadClass
    "BuiltinClassLoader.java"
    581]
   [jdk.internal.loader.ClassLoaders$AppClassLoader
    loadClass
    "ClassLoaders.java"
    178]
   [java.lang.ClassLoader loadClass "ClassLoader.java" 522]
   [java.lang.Class forName0 "Class.java" -2]
   [java.lang.Class forName "Class.java" 398]
   [clojure.lang.RT classForName "RT.java" 2212]
   [clojure.lang.RT classForNameNonLoading "RT.java" 2225]
   [ring.middleware.cookies$loading__6721__auto____19951
    invoke
    "cookies.clj"
    1]
   [ring.middleware.cookies__init load nil 1]
   [ring.middleware.cookies__init <clinit> nil -1]
   [java.lang.Class forName0 "Class.java" -2]
   [java.lang.Class forName "Class.java" 398]
   [clojure.lang.RT classForName "RT.java" 2212]
   [clojure.lang.RT classForName "RT.java" 2221]
   [clojure.lang.RT loadClassForName "RT.java" 2240]
   [clojure.lang.RT load "RT.java" 449]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 3659]
   [io.pedestal.http.ring_middlewares$loading__6721__auto____19672
    invoke
    "ring_middlewares.clj"
    13]
   [io.pedestal.http.ring_middlewares__init load nil 13]
   [io.pedestal.http.ring_middlewares__init <clinit> nil -1]
   [java.lang.Class forName0 "Class.java" -2]
   [java.lang.Class forName "Class.java" 398]
   [clojure.lang.RT classForName "RT.java" 2212]
   [clojure.lang.RT classForName "RT.java" 2221]
   [clojure.lang.RT loadClassForName "RT.java" 2240]
   [clojure.lang.RT load "RT.java" 449]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 2088]
   [io.pedestal.http$loading__6721__auto____17618 invoke "http.clj" 13]
   [io.pedestal.http__init load nil 13]
   [io.pedestal.http__init <clinit> nil -1]
   [java.lang.Class forName0 "Class.java" -2]
   [java.lang.Class forName "Class.java" 398]
   [clojure.lang.RT classForName "RT.java" 2212]
   [clojure.lang.RT classForName "RT.java" 2221]
   [clojure.lang.RT loadClassForName "RT.java" 2240]
   [clojure.lang.RT load "RT.java" 449]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 551]
   [project2.web.core$loading__6737__auto____24381
    invoke
    "core.clj"
    1]
   [project2web.core__init load nil 1]
   [project2web.core__init <clinit> nil -1]
   [java.lang.Class forName0 "Class.java" -2]
   [java.lang.Class forName "Class.java" 398]
   [clojure.lang.RT classForName "RT.java" 2212]
   [clojure.lang.RT classForName "RT.java" 2221]
   [clojure.lang.RT loadClassForName "RT.java" 2240]
   [clojure.lang.RT load "RT.java" 449]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 2422]
   [project2core$loading__6737__auto____175
    invoke
    "core.clj"
    1]
   [project2core__init load nil 1]
   [project2core__init <clinit> nil -1]
   [java.lang.Class forName0 "Class.java" -2]
   [java.lang.Class forName "Class.java" 398]
   [clojure.lang.RT classForName "RT.java" 2212]
   [clojure.lang.RT classForName "RT.java" 2221]
   [clojure.lang.RT loadClassForName "RT.java" 2240]
   [clojure.lang.RT load "RT.java" 449]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 805]
   [project.core$loading__6737__auto____175
    invoke
    "core.clj"
    1]
   [clojure.lang.AFn applyToHelper "AFn.java" 152]
   [clojure.lang.AFn applyTo "AFn.java" 144]
   [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3706]
   [clojure.lang.Compiler compile1 "Compiler.java" 7735]
   [clojure.lang.Compiler compile1 "Compiler.java" 7725]
   [clojure.lang.Compiler compile "Compiler.java" 7802]
   [clojure.lang.RT compile "RT.java" 411]
   [clojure.lang.RT load "RT.java" 457]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$compile$fn__6861 invoke "core.clj" 6125]
   [clojure.core$compile invokeStatic "core.clj" 6125]
   [clojure.core$compile invoke "core.clj" 6117]
   [user$eval159$fn__168 invoke "form-init16366169281287939199.clj" 1]
   [user$eval159 invokeStatic "form-init16366169281287939199.clj" 1]
   [user$eval159 invoke "form-init16366169281287939199.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7181]
   [clojure.lang.Compiler eval "Compiler.java" 7171]
   [clojure.lang.Compiler eval "Compiler.java" 7171]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.Compiler loadFile "Compiler.java" 7578]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$init_opt invokeStatic "main.clj" 477]
   [clojure.main$init_opt invoke "main.clj" 477]
   [clojure.main$initialize invokeStatic "main.clj" 508]
   [clojure.main$null_opt invokeStatic "main.clj" 542]
   [clojure.main$null_opt invoke "main.clj" 539]
   [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 "org.joda.time.DateTime",
  :phase :execution}}

It happens in an umbrella project where five different sub-projects are imported using Leiningen’s checkout dependencies. This morning removing the checkouts folder fixed the issue. But the error came later in the evening. Even then, the checkout folder was not present.
It also happens for three different dependencies that are shared among these five sub-projects. io.pedestal.HTTP, io.pedestal.ring-middleware, and org.joda.time`.
What is causing this? And how can I fix it? Your help would be greatly appreciated.
I really appreciate any help you can provide.

Here’s the repo containing more info and cmd outputs. Any help would be appreciated.

It looks like a misconfigured class path. I have never used lein checkouts, so I can’t help there, sorry. Have you upgraded anything immediately prior to the breaking? Any changes in your lein setup?

I’m not at a computer, so all I can do is provide suggestions based on the error. But I hope that helps a little. :slightly_smiling_face:

These scenarios are hard to debug and can have multiple root cause.

It helps if you can print the classpath, then you can see if joda time seems to be missing from it, or if something weird is happening where it shows up multiple times for example.

Thanks, @didibus. I uploaded the lein deps :tree and lein classpath cmd results here. The thing is, when you look at lein deps :tree, there is no joda dependency there.
@hiredman on slack mentioned something about some of the dependencies that could be AOT compiled when a certain joda dep was present. Is it related? But then I couldn’t figure out which dep and Why it happened all of a sudden? - We had new commits pushed the day before, but no dependencies were modified.

Thanks @mdiin. The thing is we had new commits pushed the day before but no dependencies were changed. lein or java was not updated on hosts so what could possible cause that. I figured it might have something to do with lein checkouts but on some systems the problem occurred even when running simple lein do clean, compile :all.
Here’s a link to a repo with the output of lein commands deps tree and classpath.
I appreciate your help.

I am struck by the number of, as lein puts it, “possibly confusing dependencies”. I see that you are using a lot of SNAPSHOT releases of van-buren libs, where the suggestions indicate that the underlying version they resolve to was updated very recently. See e.g. this:

Possibly confusing dependencies found:
[io.pedestal/pedestal.service-tools "0.5.7"]
 overrides
[van-buren-sle-router "0.1.0-SNAPSHOT"] -> [io.pedestal/pedestal.service-tools "0.5.10"]

Consider using these exclusions:
[van-buren-sle-router "0.1.0-20220411.202706-13" :exclusions [io.pedestal/pedestal.service-tools]]

That is from the top of the lein.deps.tree.err file. Notice that it suggests a particular version 0.1.0-20220411.202706-13 instead of the SNAPSHOT. The same scenario seems to apply to a lot of the van-buren deps. I would check the repos for those libraries to see what changed in the last couple of days.

So actually, while you might think no dependencies changed, it seems the SNAPSHOT dependencies might actually have changed.

1 Like

You’re right @mdiin. Those are our internal libraries and probably the cause of something like this. But still, we couldn’t figure out what exactly was the source of this behavior. Since none of the related dependencies that lein deps showed us were related, were changed in the past week or so.

Finally the error went away when some of my teammates added :gen-class to the main namespaces of some of the main namespaces of these van-buren libraries and the error went away somehow.

Thanks again

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.