NullPointerException
I turned on cloverage with a new repo and got this stacktrace. Any ideas? Works on a bunch of other repos we have.
java.lang.NullPointerException: Cannot invoke "java.lang.ClassLoader.getResources(String)" because the return value of "java.lang.Class.getClassLoader()" is null
at kaocha.plugin.cloverage$run_cloverage.invokeStatic (cloverage.clj:145)
kaocha.plugin.cloverage$run_cloverage.invoke (cloverage.clj:139)
kaocha.plugin.cloverage$cloverage_main_hook.invokeStatic (cloverage.clj:185)
kaocha.plugin.cloverage$cloverage_main_hook.invoke (cloverage.clj:154)
clojure.lang.AFn.applyToHelper (AFn.java:154)
clojure.lang.AFn.applyTo (AFn.java:144)
clojure.core$apply.invokeStatic (core.clj:669)
clojure.core$apply.invoke (core.clj:662)
kaocha.plugin$run_hook_STAR_$fn__2305.invoke (plugin.clj:91)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core$reduce.invokeStatic (core.clj:6885)
clojure.core$reduce.invoke (core.clj:6868)
kaocha.plugin$run_hook_STAR_.invokeStatic (plugin.clj:89)
kaocha.plugin$run_hook_STAR_.doInvoke (plugin.clj:88)
clojure.lang.RestFn.invoke (RestFn.java:445)
clojure.lang.AFn.applyToHelper (AFn.java:160)
clojure.lang.RestFn.applyTo (RestFn.java:132)
clojure.core$apply.invokeStatic (core.clj:673)
clojure.core$apply.invoke (core.clj:662)
kaocha.plugin$run_hook.invokeStatic (plugin.clj:100)
kaocha.plugin$run_hook.doInvoke (plugin.clj:99)
clojure.lang.RestFn.invoke (RestFn.java:425)
kaocha.runner$run$fn__3340.invoke (runner.clj:130)
clojure.lang.AFn.applyToHelper (AFn.java:152)
clojure.lang.AFn.applyTo (AFn.java:144)
clojure.core$apply.invokeStatic (core.clj:667)
clojure.core$with_bindings_STAR_.invokeStatic (core.clj:1990)
clojure.core$with_bindings_STAR_.doInvoke (core.clj:1990)
clojure.lang.RestFn.invoke (RestFn.java:425)
kaocha.runner$run.invokeStatic (runner.clj:129)
kaocha.runner$run.invoke (runner.clj:72)
kaocha.runner$_main_STAR_.invokeStatic (runner.clj:165)
kaocha.runner$_main_STAR_.doInvoke (runner.clj:143)
clojure.lang.RestFn.invoke (RestFn.java:397)
clojure.lang.AFn.applyToHelper (AFn.java:152)
clojure.lang.RestFn.applyTo (RestFn.java:132)
clojure.core$apply.invokeStatic (core.clj:667)
clojure.core$apply.invoke (core.clj:662)
kaocha.runner$_main.invokeStatic (runner.clj:176)
kaocha.runner$_main.doInvoke (runner.clj:174)
clojure.lang.RestFn.invoke (RestFn.java:397)
Running lein 2.11.2 and java 17.0.13.
It appears to be an issue with code that uses a class loader to load a Clojure file as a resource.
Unfortunately, Java's classloader system is pretty complicated, so it seems like this could hinge on some fairly subtle nuances of an obscure part of the JVM or even something specific to your Java implementation. (Although if your repos all use the same implementation of Java, we can rule that out.) I think it's possible for your application or its dependencies to affect what classloaders are in play, although I think the way kaocha-cloverage uses the classloader shouldn't be affected by that.
Just in case, what version of Clojure are you using? Clojure 1.12 added some features allowing dynamically loading librarie, and it's conceivable that would affect kaocha-cloverage's classloader usage.
Lol, I completely forgot Laurence and I already investigated this in #17. Unfortunately, it seems like updating Leiningen doesn't fix the issue, as you have a significantly later version that he does. It's also probably not Clojure 1.12—even if you are running that—as this issue was appearing prior to 1.12's release.
Regardless of the actual cause, I wonder if there's a better way to load a resource (or to go one step back, get a class loader) rather than trying to get to the bottom of why our current approach fails. Apparently, there's a couple different ways.
I got a chance to fiddle with this some more. It turns out the repo I see this in is a lein plugin that has :eval-in-leiningen true in project.clj. I tried dropping the line, but the plugin depends on a few internal leiningen namespaces so I think I'm just going to remove cloverage for this repo. Every other project I have is working fine. Thanks!