This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-16
Channels
- # announcements (2)
- # asami (5)
- # babashka (52)
- # beginners (42)
- # biff (3)
- # cljdoc (4)
- # cljsrn (2)
- # clojure (30)
- # clojure-austin (35)
- # clojure-dev (3)
- # clojure-france (11)
- # clojurescript (36)
- # conjure (6)
- # cursive (5)
- # fulcro (33)
- # graalvm (41)
- # lsp (54)
- # malli (1)
- # music (2)
- # off-topic (7)
- # overtone (1)
- # pedestal (5)
- # polylith (2)
- # remote-jobs (1)
- # sci (28)
- # shadow-cljs (38)
- # vim (15)
- # web-security (1)
- # xtdb (8)
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)...
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
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.
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?
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"
is compilation succeeding? does the code work when run normally as clojure?
those exceptions don't necessarily look native-image related
but when I try a url with a simple db access (thing that works with clojure jar) it throws that exception
I would recommend finding or creating a simple example that only connects to the db.
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.