scalaelasticsearchsbt

How to resolve ElasticSearch Library Dependency Error


I'm trying to setup an ElasicSearch client using Scala. I'm new to Scala, so I'm following some online tutorials suggesting elastic4s-client-esjava. I've got that setup in my build.sbt with the rest of my library dependencies below:

name := "ElasticSearchService"

version := "0.1"

scalaVersion := "3.5.2"

libraryDependencies ++= Seq(
  "org.postgresql" % "postgresql" % "42.3.1",
  "nl.gn0s1s" %% "elastic4s-client-esjava" % "8.11.5",
  "nl.gn0s1s" %% "elastic4s-core" % "8.11.5"
)

When I try to run sbt run I get an error sbt.librarymanagement.ResolveException: Error downloading nl.gn0s1s:elastic4s-client-esjava_3:8.11.5 NOT FOUND. I've verified that the packages and versions exist here: https://mvnrepository.com/artifact/com.sksamuel.elastic4s/elastic4s-client-esjava and https://mvnrepository.com/artifact/com.sksamuel.elastic4s/elastic4s-core. I'm wondering if something about my setup or configuration is incorrect. Before I added ElasticSearch library dependency the project was working fine (with the postgres dependency only).

Any assistance on how to resolve this would be much appreciated! The full error log is below for reference:

env@C02FD6JFMD6R-MacBook-Pro ElasticSearchService % sbt run  
[info] welcome to sbt 1.10.3 (Homebrew Java 23)
[info] loading project definition from /Users/env/Desktop/ElasticSearchService/ElasticSearchService/project
[info] loading settings for project elasticsearchservice from build.sbt ...
[info] set current project to ElasticSearchService (in build file:/Users/env/Desktop/ElasticSearchService/)
[info] Updating elasticsearchservice_3
[info] Resolved elasticsearchservice_3 dependencies
[warn] 
[warn]  Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading nl.gn0s1s:elastic4s-client-esjava_3:8.11.5
[error]   Not found
[error]   Not found
[error]   not found: /Users/env/.ivy2/localnl.gn0s1s/elastic4s-client-esjava_3/8.11.5/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/nl/gn0s1s/elastic4s-client-esjava_3/8.11.5/elastic4s-client-esjava_3-8.11.5.pom
[error] Error downloading nl.gn0s1s:elastic4s-core_3:8.11.5
[error]   Not found
[error]   Not found
[error]   not found: /Users/env/.ivy2/localnl.gn0s1s/elastic4s-core_3/8.11.5/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/nl/gn0s1s/elastic4s-core_3/8.11.5/elastic4s-core_3-8.11.5.pom
[error]         at lmcoursier.CoursierDependencyResolution.unresolvedWarningOrThrow(CoursierDependencyResolution.scala:346)
[error]         at lmcoursier.CoursierDependencyResolution.$anonfun$update$39(CoursierDependencyResolution.scala:315)
[error]         at scala.util.Either$LeftProjection.map(Either.scala:573)
[error]         at lmcoursier.CoursierDependencyResolution.update(CoursierDependencyResolution.scala:315)
[error]         at sbt.librarymanagement.DependencyResolution.update(DependencyResolution.scala:60)
[error]         at sbt.internal.LibraryManagement$.resolve$1(LibraryManagement.scala:60)
[error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$12(LibraryManagement.scala:142)
[error]         at sbt.util.Tracked$.$anonfun$lastOutput$1(Tracked.scala:74)
[error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11(LibraryManagement.scala:144)
[error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11$adapted(LibraryManagement.scala:131)
[error]         at sbt.util.Tracked$.$anonfun$inputChangedW$1(Tracked.scala:220)
[error]         at sbt.internal.LibraryManagement$.cachedUpdate(LibraryManagement.scala:169)
[error]         at sbt.Classpaths$.$anonfun$updateTask0$1(Defaults.scala:3894)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error]         at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error]         at sbt.Execute.work(Execute.scala:292)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[error]         at java.base/java.lang.Thread.run(Thread.java:1575)
[error] (update) sbt.librarymanagement.ResolveException: Error downloading nl.gn0s1s:elastic4s-client-esjava_3:8.11.5
[error]   Not found
[error]   Not found
[error]   not found: /Users/env/.ivy2/localnl.gn0s1s/elastic4s-client-esjava_3/8.11.5/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/nl/gn0s1s/elastic4s-client-esjava_3/8.11.5/elastic4s-client-esjava_3-8.11.5.pom
[error] Error downloading nl.gn0s1s:elastic4s-core_3:8.11.5
[error]   Not found
[error]   Not found
[error]   not found: /Users/env/.ivy2/localnl.gn0s1s/elastic4s-core_3/8.11.5/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/nl/gn0s1s/elastic4s-core_3/8.11.5/elastic4s-core_3-8.11.5.pom
[error] Total time: 1 s, completed Oct 23, 2024, 9:47:03 a.m.

Solution

  • Yeah, sorry for not being clear. It seems at some point in time, the library changed owners from sksamuel; who used the domain / organization com.sksamuel.elastic4s to Philippus; who is using the domain / organization nl.gn0s1s.
    (IIRC, this is actually quite recent, but is been a while since I looked at anything ElasticSearch related).

    As such, newer versions are in the nl.gn0s1s space: https://mvnrepository.com/artifact/nl.gn0s1s/elastic4s-core and older versions are in the com.sksamuel.elastic4s space: https://mvnrepository.com/artifact/com.sksamuel.elastic4s/elastic4s-core

    Thus, you can either use the latest version: 8.15.3 released in the nl.gn0s1s space.
    Or use the version you originally posted; 8.11.5, but changing the space to com.sksamuel.elastic4s
    IMHO, it is better to use the latest, but you may be following an outdated tutorial and as such it may be easier to stick with the version of that tutorial.