Fork me on GitHub
#graalvm
<
2022-04-16
>
_II_23:04:34

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_23:04:56

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_23:04:07

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_23:04:10

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_23:04:26

Is it even possible?

phronmophobic23:04:06

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

phronmophobic23:04:07

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.

_II_23:04:45

thank you very much

_II_00:04:20

maybe really postgresql would work

phronmophobic00:04:27

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_00:04:29

well it's too much java for me

_II_00:04:52

can't find anything about mariadb.properties in google

_II_00:04:10

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

phronmophobic01:04:38

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

_II_01:04:20

well I would just be so happy to achieve this

_II_01:04:08

would be really cool to make a native image simple webapp

_II_01:04:51

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

_II_01:04:52

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

_II_01:04:24

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

_II_01:04:54

maybe something about the protocol

phronmophobic01:04:30

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

phronmophobic01:04:00

those exceptions don't necessarily look native-image related

_II_01:04:35

it works normally as a jar file

_II_01:04:44

mysql, mariadb

_II_01:04:53

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

_II_01:04:43

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

_II_01:04:07

there is something wrong maybe with jdbc -> native

_II_01:04:20

something with the connection

phronmophobic01:04:21

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

_II_01:04:33

already tried

_II_01:04:11

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

_II_01:04:27

and no clear tutorials on this subject

_II_01:04:32

it's weird man

_II_01:04:57

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

_II_02:04:51

anyway thank you very much

Karol Wójcik08:04:26

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.