Fork me on GitHub
#graalvm
<
2020-09-08
>
Ashwin Bhaskar05:09:34

i am trying to make https://github.com/ashwinbhaskar/aerospike-migration 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: java.io.FileNotFoundException: Could not locate clojure/core__init.class, clojure/core.clj or clojure/core.cljc on classpath.
	at clojure.lang.RT.load(RT.java:466)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.lang.RT.doInit(RT.java:471)
	at clojure.lang.RT.<clinit>(RT.java:338)
	at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
	at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
Has anyone faced such an error?

phronmophobic06:09:48

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

borkdude11:09:53

@UKH3WV6TH Check the contents of you uberjar

borkdude12:09:08

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

borkdude12:09:47

What is your native-image invocation?

borkdude12:09:22

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 clojure.tools.logging.proxy$java.io.ByteArrayOutputStream$ff19274a.flush(Unknown Source)
	at java.io.PrintStream.flush(PrintStream.java:338)
	at com.oracle.svm.jni.functions.JNIFunctions.ExceptionDescribe(JNIFunctions.java:772)
	at com.oracle.svm.core.code.IsolateEnterStub.JNIFunctions_ExceptionDescribe_b5412f7570bccae90b000bc37855f00408b2ad73(generated:0)
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]

borkdude12:09:31

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: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: 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?

borkdude14:09:30

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!