graalvm

_II_ 2022-04-16T23:32:34.488859Z

Hello, I'm trying to make a simple test accesing a database, but all my native-images always have problems no matter if I try to use mysql, mariadb, mongo

_II_ 2022-04-16T23:33:56.093529Z

I've achieved jetty working ok with this native-image --no-fallback --no-server --allow-incomplete-classpath --report-unsupported-elements-at-runtime --initialize-at-build-time=. --enable-url-protocols=http,https --static -jar jarname.jar

_II_ 2022-04-16T23:35:07.977149Z

but when I try to acces mariadb with com.github.seancorfield/next.jdbc and rg.mariadb.jdbc/mariadb-java-client, from native-image I have:

_II_ 2022-04-16T23:35:10.773959Z

property file 'mariadb.properties' not found in the classpath 2022-04-17 01:30:44.676:WARN:oejs.HttpChannel:qtp285690803-84: / java.lang.NullPointerException: inStream parameter is null at java.util.Objects.requireNonNull(Objects.java:233) at java.util.Properties.load(Properties.java:407)...

_II_ 2022-04-16T23:35:26.095999Z

Is it even possible?

phronmophobic 2022-04-16T23:43:06.764859Z

It seems like it should be possible in principle since https://github.com/babashka/babashka-sql-pods does it.

phronmophobic 2022-04-16T23:44:07.056259Z

I haven't hooked up any dbs from native image, but you might be able to use babashka-sql-pods to figure out what configs are needed.

phronmophobic 2022-04-16T23:45:08.953159Z

there's also an example with next-jdbc https://github.com/clj-easy/graalvm-clojure/tree/master/next-jdbc

_II_ 2022-04-16T23:47:45.481209Z

thank you very much

_II_ 2022-04-17T00:00:20.651139Z

maybe really postgresql would work

phronmophobic 2022-04-17T00:19:27.633959Z

the error you have doesn't look like it's directly graalvm related. It seems like it's looking for mariadb.properties and can't find it. Not sure if that's a library file or a local property file it can't find. Either way, you should be able to put the properties in a file where the compiled version can find it or provide the properties some other way.

_II_ 2022-04-17T00:47:29.412289Z

well it's too much java for me

_II_ 2022-04-17T00:47:52.139909Z

can't find anything about mariadb.properties in google

_II_ 2022-04-17T00:51:10.374509Z

I'm at the point where I really don't know what I'm doing, moving parameters, trying to compile

phronmophobic 2022-04-17T01:08:38.654409Z

what's you're reasoning for using native-image rather than either regular clojure or babashka?

_II_ 2022-04-17T01:20:20.998099Z

well I would just be so happy to achieve this

_II_ 2022-04-17T01:20:23.500579Z

: )

_II_ 2022-04-17T01:22:08.247789Z

would be really cool to make a native image simple webapp

_II_ 2022-04-17T01:23:51.721739Z

but as I really don't know java it's quite difficult to make sense of the conversion error messages

_II_ 2022-04-17T01:27:52.917199Z

now with mysql "java.lang.ClassCastException: com.mysql.cj.exceptions.CJException cannot be cast to com.mysql.cj.exceptions.WrongArgumentException"

_II_ 2022-04-17T01:28:24.486429Z

it's probably because something is failing and it throws an exception

_II_ 2022-04-17T01:29:54.694739Z

maybe something about the protocol

phronmophobic 2022-04-17T01:33:30.842389Z

is compilation succeeding? does the code work when run normally as clojure?

phronmophobic 2022-04-17T01:34:00.948679Z

those exceptions don't necessarily look native-image related

_II_ 2022-04-17T01:40:20.781959Z

yes

_II_ 2022-04-17T01:40:35.552309Z

it works normally as a jar file

_II_ 2022-04-17T01:40:44.776789Z

mysql, mariadb

_II_ 2022-04-17T01:42:53.452689Z

and once I have a native-image it works where a jetty serves a page with no db access

_II_ 2022-04-17T01:43:43.316419Z

but when I try a url with a simple db access (thing that works with clojure jar) it throws that exception

_II_ 2022-04-17T01:44:07.910479Z

there is something wrong maybe with jdbc -> native

_II_ 2022-04-17T01:44:20.115099Z

something with the connection

phronmophobic 2022-04-17T01:52:21.161029Z

I would recommend finding or creating a simple example that only connects to the db.

_II_ 2022-04-17T01:52:33.709039Z

already tried

_II_ 2022-04-17T01:52:35.741439Z

nothing

_II_ 2022-04-17T01:53:11.183469Z

Im really surprised that there is no many people trying to do this

_II_ 2022-04-17T01:53:27.218799Z

and no clear tutorials on this subject

_II_ 2022-04-17T01:53:32.481369Z

it's weird man

_II_ 2022-04-17T01:53:57.960469Z

what are you people doing with this stuff if you are not connecting to a database?

_II_ 2022-04-17T01:53:58.678399Z

xD

_II_ 2022-04-17T02:01:51.627099Z

anyway thank you very much

Karol Wójcik 2022-04-18T08:00:26.653249Z

XD You have to add the property files to the list of resources that should be embedded into a native image. Plenty of us are doing it.