This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-14
Channels
- # announcements (2)
- # aws (1)
- # babashka (18)
- # babashka-sci-dev (103)
- # beginners (165)
- # calva (51)
- # cider (8)
- # circleci (1)
- # clj-kondo (22)
- # clj-on-windows (2)
- # cljdoc (1)
- # cljfx (31)
- # cljs-dev (16)
- # clojure (81)
- # clojure-europe (71)
- # clojure-nl (7)
- # clojure-uk (11)
- # clojurescript (20)
- # code-reviews (26)
- # conjure (1)
- # contributions-welcome (1)
- # core-async (15)
- # cursive (8)
- # datomic (8)
- # defnpodcast (2)
- # eastwood (24)
- # emacs (10)
- # events (1)
- # fulcro (4)
- # funcool (31)
- # graalvm (43)
- # graphql (8)
- # honeysql (9)
- # introduce-yourself (1)
- # jobs (12)
- # kaocha (3)
- # lsp (28)
- # malli (4)
- # meander (4)
- # membrane (7)
- # off-topic (64)
- # other-languages (3)
- # pedestal (1)
- # polylith (31)
- # portal (5)
- # re-frame (4)
- # reitit (1)
- # releases (5)
- # rum (2)
- # schema (2)
- # sci (34)
- # shadow-cljs (21)
- # vscode (1)
Hey guys 👋 I am using graal-build-time
and a tiny compile script to try and build a native image from an uberjar, but native-image
always breaks saying certain classes where initialized at build time, even though I went through them and passed them to the --initialize-at-run-time
option.
@U013SKZJM39 Just add com.fasterxml
to the list
We also have a solution for this here: https://github.com/clj-easy/graal-config if you are using cheshire, supposedly
Hmm not cheshire in particular, but maybe one of the other deps depends on it
I’m using etaoin
and some CLI option parsing, so it’s likely a transitive dep somewhere
Thanks, I’ll take a look later 🙇
Oh for Babashka? :thinking_face: yeah that would be very useful
Yes:
(require '[babashka.pods :as pods])
(pods/load-pod 'org.babashka/etaoin "0.1.0")
;; or for loading local binary: (pods/load-pod "./pod-babashka-etaoin")
(require '[pod.babashka.etaoin :as eta])
(def driver (eta/firefox))
(eta/go driver "")
(eta/quit driver)
so I looked at graal-config
examples and merged the options and reflection configs, and I got much further now :thumbsup:
now I’m just stuck on this error and can’t wrap my head around it:
Error: Classes that should be initialized at run time got initialized during image building:
java.security.Security the class was requested to be initialized at run time (from the command line). To see why java.security.Security got initialized use --trace-class-initialization=java.security.Security
java.security.SecureRandom the class was requested to be initialized at run time (from the command line). To see why java.security.SecureRandom got initialized use --trace-class-initialization=java.security.SecureRandom
java.security.MessageDigest the class was requested to be initialized at run time (from the command line). To see why java.security.MessageDigest got initialized use --trace-class-initialization=java.security.MessageDigest
My config so far
I have a separate project here on which I based the pod: https://github.com/borkdude/etaoin-graal where I changed some stuff. Maybe it's useful going into that.
hm I was debugging a bit more and hit this one:
Error: Incompatible change of initialization policy for com.sun.jndi.dns.DnsClient: trying to change RUN_TIME from the command line to RERUN Contains Random references, therefore can't be included in the image heap.
com.oracle.svm.core.util.UserError$UserException: Incompatible change of initialization policy for com.sun.jndi.dns.DnsClient: trying to change RUN_TIME from the command line to RERUN Contains Random references, therefore can't be included in the image heap.
basically the root of the problem is java.security.SecureRandom
nope, no bare HTTP calls, just using etaoin
APIs
(defn setup-driver
([] (setup-driver true))
([headless?]
(let [driver (api/chrome {:headless headless?})]
(api/set-window-size driver 1200 800)
driver)))
Hmm could be, should I try your fork then?
Ok I tried the fork, still getting this:
Error: Classes that should be initialized at run time got initialized during image building:
sun.security.jca.JCAUtil the class was requested to be initialized at run time (from the command line). sun.security.jca.JCAUtil has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of sun.security.jca.JCAUtil
java.security.SecureRandom the class was requested to be initialized at run time (from the command line). com.sun.jndi.dns.DnsClient caused initialization of this class with the following trace:
at java.security.SecureRandom.<clinit>(SecureRandom.java:152)
at sun.security.jca.JCAUtil$CachedSecureRandomHolder.<clinit>(JCAUtil.java:59)
at sun.security.jca.JCAUtil.getSecureRandom(JCAUtil.java:69)
at com.sun.jndi.dns.DnsClient.<clinit>(DnsClient.java:84)
My script:
"native-image" \
-jar target/uberjar/atoss-cli-standalone.jar \
-H:Name=atoss-native \
-H:+ReportExceptionStackTraces \
--initialize-at-run-time=org.apache.commons.logging.LogFactory,org.apache.http.conn.ssl.AbstractVerifier,org.apache.http.Consts,org.apache.http.conn.ssl.BrowserCompatHostnameVerifier,org.apache.http.nio.conn.ssl.SSLIOSessionStrategy,org.apache.http.conn.ssl.AllowAllHostnameVerifier,com.fasterxml.jackson.dataformat.cbor.CBORFactory,com.fasterxml.jackson.dataformat.smile.SmileFactory,com.fasterxml.jackson.core.JsonFactory,org.apache.http.conn.ssl.StrictHostnameVerifier,org.apache.http.conn.ssl.SSLConnectionSocketFactory \
--no-fallback \
--no-server \
"-J-Xmx3g"
What native-image
logged
Don’t think it’s related to Graal’s version, but just in case its [email protected]
Encountering build errors that I think are related to incomplete trace
info, but i can’t really tell.
https://github.com/bowbahdoe/jproject/runs/4823295129?check_suite_focus=true
@emccue are you trying to compile tools.build to native? check out https://github.com/babashka/tools-deps-native and https://github.com/babashka/tools.bbuild
I got the compile working and an exe that will run by copying the flags from the tools-deps-native project and using clj-easy, but for whatever reason it won’t see a deps.edn
in the directory i run it in
This is likely because you are using a def
somewhere which reads things at compile time rather than at run time.
but im gonna have to shelve this while i learn stuff since seeing this https://github.com/sormuras/bach makes me realize i dont understand modules nearly enough yet