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
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
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:
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)...
Is it even possible?
It seems like it should be possible in principle since https://github.com/babashka/babashka-sql-pods does it.
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.
there's also an example with next-jdbc https://github.com/clj-easy/graalvm-clojure/tree/master/next-jdbc
thank you very much
maybe really postgresql would work
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.
well it's too much java for me
can't find anything about mariadb.properties in google
I'm at the point where I really don't know what I'm doing, moving parameters, trying to compile
what's you're reasoning for using native-image rather than either regular clojure or babashka?
well I would just be so happy to achieve this
: )
would be really cool to make a native image simple webapp
but as I really don't know java it's quite difficult to make sense of the conversion error messages
now with mysql "java.lang.ClassCastException: com.mysql.cj.exceptions.CJException cannot be cast to com.mysql.cj.exceptions.WrongArgumentException"
it's probably because something is failing and it throws an exception
maybe something about the protocol
is compilation succeeding? does the code work when run normally as clojure?
those exceptions don't necessarily look native-image related
yes
it works normally as a jar file
mysql, mariadb
and once I have a native-image it works where a jetty serves a page with no db access
but when I try a url with a simple db access (thing that works with clojure jar) it throws that exception
there is something wrong maybe with jdbc -> native
something with the connection
I would recommend finding or creating a simple example that only connects to the db.
already tried
nothing
Im really surprised that there is no many people trying to do this
and no clear tutorials on this subject
it's weird man
what are you people doing with this stuff if you are not connecting to a database?
xD
anyway thank you very much
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.