Fork me on GitHub
Ashwin Bhaskar05:09:34

i am trying to make command line application graalvm compatible. I am able to generate the native image with if I give --report-unsupported-elements-at-runtime parameter. But when I try to run the native image, I get this error

Caused by: Could not locate clojure/core__init.class, clojure/core.clj or clojure/core.cljc on classpath.
	at clojure.lang.RT.load(
	at clojure.lang.RT.load(
	at clojure.lang.RT.doInit(
	at clojure.lang.RT.<clinit>(
Has anyone faced such an error?


looking at the project.clj, it doesn’t look like you’re AOTing your uberjar

Ashwin Bhaskar08:09:28

doesn’t the presence of :gen-class generate the main class ahead of time?

Ashwin Bhaskar09:09:24

@U7RJTCH6J did you mean adding :aot :all to project.clj? I tried this. Still get the same error


@UKH3WV6TH Check the contents of you uberjar


with jar -tf the-uberjar.jar

Ashwin Bhaskar12:09:10

@U04V15CAJ I did that. I am able to see clojure/core__init.class in output


What is your native-image invocation?


I think it would be easier if you made a repro repo on Github

Ashwin Bhaskar12:09:09

@U04V15CAJ sure, pushed all my changes to the repo. To reproduce. 1. Clone the repo and run make create-jar 2. A jar with name aerospike-migration.jar will be created. 3. Copy the jar to the Graalvm bin directory. 4. Run ./native-image --report-unsupported-elements-at-runtime -jar aerospike-migration.jar -H:Name=aerospike-migration --no-fallback -H:+ReportExceptionStackTraces 5. A native image with the name aerospike-migration will be generated. 6. Just run ./aerospike-migration --help You should see the error that I am getting

Ashwin Bhaskar12:09:10

@U04V15CAJ using --initialize-at-build-time gives this exception while generating the native iamge

Call path from entry point to clojure.core.server$io_prepl$fn__8940.invoke(Object):
	at clojure.core.server$io_prepl$fn__8940.invoke(server.clj:284)
	at$$ff19274a.flush(Unknown Source)
Original exception that caused the problem: org.graalvm.compiler.core.common.PermanentBailoutException: Frame states being merged are incompatible: unbalanced monitors - locked objects do not match
 This frame state: [locals: [1,2,41,_,_,_,_] stack: [44] locks: [] rethrowException]
Other frame state: [locals: [1,2,41,_,_,_,_] stack: [74] locks: [51 / 42] rethrowException]
Parser context: clojure.core.server$io_prepl$fn__8940.invoke(server.clj:287) [bci: 84, intrinsic: false]


Use clojure 1.10.2-alpha1, also see the linked repo

Ashwin Bhaskar14:09:16

@U04V15CAJ Tried out as given in the linked repo and shifting to clojure 1.10.2-alpha1. Now it gives the error:

Caused by: Class initialization of org.postgresql.sspi.SSPIClient failed. Use the option --initialize-at-run-time=org.postgresql.sspi.SSPIClient to explicitly request delayed initialization of this class.
Detailed message:

Ashwin Bhaskar14:09:31

Is the postgresql jdbc driver not graal compatible?


It is, but you need an additional setting.

Ashwin Bhaskar00:09:44

Yes, using the additional setting made it work. But it complained that there no method that takes 1 argument for class CompletableFuture

Ashwin Bhaskar00:09:33

Adding type hint solved the problem. Now I am able to execute the native image fine. Thanks a lot @U04V15CAJ!