2017-01-04 4 views
0

Я пытаюсь подключиться к кластеру ES через Elastic4s. Я использую пример, приведенный в GitHub репо:Elastic4s java.lang.NoSuchMethodError

import com.sksamuel.elastic4s.ElasticClient 
import com.sksamuel.elastic4s.ElasticDsl._ 

object Test extends App { 

    val client = ElasticClient.transport(ElasticsearchClientUri(host, port)) 

    // await is a helper method to make this operation synchronous instead of async 
    // You would normally avoid doing this in a real program as it will block your thread 
    client.execute { index into "bands"/"artists" fields "name"->"coldplay" }.await 

    // we need to wait until the index operation has been flushed by the server. 
    // this is an important point - when the index future completes, that doesn't mean that the doc 
    // is necessarily searchable. It simply means the server has processed your request and the doc is 
    // queued to be flushed to the indexes. Elasticsearch is eventually consistent. 
    // For this demo, we'll simply wait for 2 seconds (default refresh interval is 1 second). 
    Thread.sleep(2000) 

    // now we can search for the document we indexed earlier 
    val resp = client.execute { search in "bands"/"artists" query "coldplay" }.await 
    println(resp) 

} 

Клиент принимает соединения на 9434, как описано здесь - https://www.elastic.co/guide/en/cloud/current/security.html#security-transport

Кроме того, он ищет или присоединяет - в зависимости от конструкции пути, выбранного - elasticsearch:\\ на хост и порт.

После запуска даже строку, которая инициализирует клиента я получаю Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)[Ljava/lang/Object;

Очевидно, я что-то недоразумение. Пожалуйста, дайте мне знать, что я делаю неправильно.

EDIT:

Как проверки У меня есть клиент .Net для ES, который использует регулярное соединение HTTP.

var node = new Uri(url); 
var connectionSettings = new ConnectionSettings(node); 
connectionSettings.BasicAuthentication(settings.username,settings.password); 
client = new ElasticClient(connectionSettings); 

Я стремлюсь достичь того же.

ответ

0

Возможно, вам не хватает библиотеки scala в ваших зависимостях. Поэтому, в зависимости от того, какую версию Scala вы используете, вам нужно, чтобы ваши отпечатки соответствовали этому. Какой инструмент сборки вы используете?

SBT (вы не должны делать это, SBT должны делать это автоматически на основании вашего scalaVersion)

"org.scala-lang" % "scala-library" % "YOUR SCALA VERSION" 

Maven

<dependency> 
    <groupId>org.scala-lang</groupId> 
    <artifactId>scala-library</artifactId> 
    <version>2.12.1</version> 
</dependency> 

SBT также имеет некоторую информацию, http://www.scala-sbt.org/1.0/docs/Configuring-Scala.html

Смежные вопросы