Hello, I'm trying to build an XTDB2 project, but get stuck
% clojure -X:uberjar :aot false :jar server.jar
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.passes, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.passes.uniquify, being replaced by: #'clojure.tools.analyzer.utils/update-vals
Building uber jar: server.jar
% java --add-opens=java.base/java.nio=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true -cp server.jar clojure.main -m et.pe.server
Syntax error compiling at (xtdb/mirrors/time_literals.clj:99:7).
Unable to resolve symbol: update-vals in this contexthere is line 99 https://github.com/xtdb/xtdb/blob/main/api/src/main/clojure/xtdb/mirrors/time_literals.clj#L99
to build, i use
:uberjar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.303"}}
:exec-fn hf.depstar/uberjar}
Hey @dan203 I don't recognise this error - can you try again with the latest SNAPSHOT coordinate?
:mvn/repos {"sonatype-snapshots" {:url ""}}
:deps {com.xtdb/xtdb-jdbc {:mvn/version "2.0.0-SNAPSHOT"} (we changed how we're using time-literals literally just last week 🙂)
Hey @taylor.jeremydavid. I tried but snapshot seems not to be available. "Could not find artifact com.xtdb:xtdb-jdbc:jar:2.0.0-SNAPSHOT in central (https://repo1.maven.org/maven2/)" Can this be?
hmm! did you register the snapshot repo also? (per the first line above)
will check it
sorry, i missed the first line. this works of course 🙂
problem persists, though
maybe that wasn't the right idea to build it with depstar, which is deprecated and i suspect now after some testing that the conflict from update-vals comes from there.
using tonsky/uberdeps looks better, but I run into another problem
$ clj -M -m uberdeps.uberjar --target server.jar
...
$ java -cp server.jar clojure.main -m et.pe.server
Syntax error compiling at (xtdb/serde.clj:193:27).
Unable to find static field: new in class xtdb.types.ClojureForm
not sure why line numbers don't match but probably this is this line https://github.com/xtdb/xtdb/blob/main/api/src/main/clojure/xtdb/serde.clj#L205
ok, fixed with org.clojure/clojure {:mvn/version "1.12.0"}
ah yes, 1.12.0 is a hard requirement
while i can now package and run the app with tonsky/uberdeps , when doing a query against a graphql endpoint, behind which xtdb sits, and which in a non-packaged situtation works, i get the following
ah, try adding juxt/tick to your deps
hm, no, that wasn't it. same error
sorry I just realised I've probably been confusing a couple of things here (not sure if you're even using xtdb-jdbc 😅) so if you're using xtdb-core etc. for in-process usage, try 2.0.0-nightly
😄 using xtdb-core, xtdb-api currently, but about to add xtdb-jdbc
my bad, should've said it earlier when you mentioned xtdb-jdbc
but the nightly isn't in the snapshots repo, no?
I don't need to necessarily package for the foreseeable time, was just doing some exploration and so on. But thought it might be interesting to find out what's going on. So for reference, I narrowed things down in a branch to a minimal example.
https://github.com/eighttrigrams/personalist/tree/narrow-down-xtdb2-uberjar-issue
oops...yeah, more confusion on my part again, -nightly is a Docker thing, nothing to do with the maven deps facepalm thanks for sharing the repro
this is not my area of expertise, but ChatGPT is suggesting a clojure -e "(require 'build-init)" ... build step might help (though I presume there's something we can do in the core to make uberjar work without this):
(ns build-init
(:require [xtdb.types]))
;; Optionally ensure that the data readers are available explicitly.
;; Not typically necessary if XTDB handles this automatically.
(when-not (contains? *data-readers* 'xt/date)
(throw (ex-info "Reader for #xt/date is not registered" {})))I'll just note that depstar has been deprecated for a long time and I strongly recommend learning to use tools.builds for a standardized uberjar experience.
You can get a good sense of what a minimal application project with build.clj etc looks like using deps-new: clojure -Tnew app :name my-xtdb/example
The various other uberjar libraries out there have "opinions" and if you run into problems, it's going to be harder for folks to assist you.
@taylor.jeremydavid I couldn't make that last suggestion work. But I took @seancorfield’s suggestion to heart and looked into tools.build which worked out beautifully. An uberjar produced with it worked perfectly! Thank you both.