Fork me on GitHub
#xtdb
<
2024-05-16
>
Stef Coetzee11:05:16

How might one go about starting an XTDB v2 HTTP server locally, which can be interacted with from a separate client project (also running locally)?

Stef Coetzee11:05:57

So far, I have deps.edn as:

{:paths ["src"]
 
 :mvn/repos {"sonatype-snapshots" {:url ""}}

 :deps      {org.clojure/clojure  {:mvn/version "1.11.1"}
             com.xtdb/xtdb-core   {:mvn/version "2.0.0-SNAPSHOT"}
             com.xtdb/xtdb-api    {:mvn/version "2.0.0-SNAPSHOT"}
             com.xtdb/xtdb-http-server {:mvn/version "2.0.0-SNAPSHOT"}} ; fixed, was specified as com.xtdb/xtdb-server, which does not exist and caused the error

 :aliases   {:xtdb {:jvm-opts ["--add-opens=java.base/java.nio=ALL-UNNAMED"
                               "-Dio.netty.tryReflectionSetAccessible=true"]}}}

Stef Coetzee11:05:06

When starting the REPL with

clojure \
-Sdeps '{:deps {nrepl/nrepl       {:mvn/version,"1.0.0"},
                cider/cider-nrepl {:mvn/version,"0.28.5"}}}' \
-M:xtdb -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
I encounter the following error: Error building classpath. Could not find artifact com.xtdb:xtdb-server:jar:2.0.0-SNAPSHOT in central (https://repo1.maven.org/maven2/) The alternative repository is specified under :mvn/repos. Not sure what might cause the error.

refset16:05:21

Hey @U03CPPKDXBL that seems odd, can't see an obvious explanation. Can you access the repository URL in your browser okay? https://s01.oss.sonatype.org/content/repositories/snapshots (i.e. maybe it's getting blocked somehow?)

Stef Coetzee16:05:25

Ah! Typo in the XTDB server dependency specification. com.xtdb/xtdb-server should be com.xtdb/xtdb-http-server. (Checked the https://docs.xtdb.com/config/modules/http-server.)

refset16:05:55

ah! well spotted. Do you remember if you copy-pasted that from somewhere that I might need to hunt down and fix? πŸ™‚

Stef Coetzee16:05:31

Thanks! Safe to say this was due to operator error. πŸ˜‰

☺️ 1
πŸ‘ 1
Stef Coetzee17:05:29

Continuing on from the initial entry in the thread, xtdb.edn can be specified in the project root:

;; ./xtdn.edn
{:log         [:local {:path "/tmp/xtdb2/tx-log"}]
 
 :storage     [:local {:path "/var/lib/xtdb2/storage"}]
 
 :http-server {:port 3000}}

Stef Coetzee17:05:28

The server can be started from the command line via clojure -M:xtdb -m xtdb.main .

Stef Coetzee17:05:32

This server can be interacted with as described in the https://docs.xtdb.com/drivers/clojure/getting-started#_connecting_through_http.

πŸ‘ 1