I'm trying to make a native image of a clojure application of mine that's a very simple command-line wrapper around kibit, https://gitlab.com/tvaughan/kibit-runner/-/tree/master/kibit-runner/src/kibit_runner. To compile this I run:
clojure -A:depstar:$@ dist/kibit-runner-standalone.jar -C -m kibit-runner.cmdline
native-image \
-jar dist/kibit-runner-standalone.jar \
dist/kibit-runner \
--initialize-at-build-time=clojure \
--report-unsupported-elements-at-runtime \
--no-server
And when I run this I get:
[root@f092da83da6c kibit-runner]# ./dist/kibit-runner
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:291)
Caused by: java.io.FileNotFoundException: Could not locate clojure/core/server__init.class, clojure/core/server.clj or clojure/core/server.cljc on classpath.
at clojure.lang.RT.load(RT.java:462)
at clojure.lang.RT.load(RT.java:424)
at clojure.core$load$fn__6839.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__6780.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 clojure.lang.Var.invoke(Var.java:384)
at clojure.lang.RT.doInit(RT.java:491)
at clojure.lang.RT.init(RT.java:467)
at clojure.lang.Util.loadWithClass(Util.java:248)
at kibit_runner.cmdline.<clinit>(Unknown Source)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
This seems to say that the application is trying to start a socket repl of some sort but why? Anyone have any clue what's going on?The stacktrace occurs at runtime, not compile time
I get the same issue if I use initialize-at-build-time=clojure. If I just use initialize-at-build-time then things appear fine but that causes other issues.
I tried numerous different combinations myself, each with different errors
are you aot compiling everything?
I think so. I'm using the -C
option in depstar to compile the uberjar, https://github.com/seancorfield/depstar#aot-compilation
require
allows you to specify you can load it verbosely: https://clojuredocs.org/clojure.core/require
I would try requiring verbosely and seeing if that helps track down what might be using clojure.server
nothing jumps out as a problem with your usage. I might try starting with a simple -main that just prints something and progressively add the dependencies and functionality to try to narrow down what might be the issue. it's a little tricky though since native-image does a pretty good job of only trying to only include necessary dependenciies
What should I look for in this output? I don't see any namespace being loaded that contains the string server
I appreciate the help. Thanks
it should be printing out the order in which namespaces are loaded. i was hoping the last print before the stack trace would identify the culprit