21

My code is working fine in elasticsearch 5 but when I have upgraded from 5 to 6 then. it is showing

org.elasticsearch.common.transport.InetSocketTransportAddress not found

complete stack trace:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project elastic-store: Compilation failure
[ERROR] /home/elastic/elastic-store/src/main/java/com/qw/psence/store/es/common/ESClient.java:[12,42] cannot find symbol
[ERROR] symbol:   class InetSocketTransportAddress
[ERROR] location: package org.elasticsearch.common.transport
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]

can anyone help me to resolve this problem?

Note: Elaticsearch jar is fine.

Arayan Singh
  • 3,192
  • 3
  • 16
  • 35

3 Answers3

47

Elastic search 6.0 has removed InetSocketTransportAddress class. I have solved this By replacing InetSocketTransportAddress class with TransportAddress class.

// on startup

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
        .addTransportAddress(new TransportAddress(InetAddress.getByName("host1"), 9300))
        .addTransportAddress(new TransportAddress(InetAddress.getByName("host2"), 9300));

// on shutdown

client.close();
Arayan Singh
  • 3,192
  • 3
  • 16
  • 35
0

There are many solutions offered to the problem, but I was getting this error because, as I was trying to make a basic elasticsearch configuration with SpringBoot:

I forgot to start elasticsearch...

:facepalm:

So, just:

  1. open command line at bin folder in your Elasticsearch installation directory*
  2. type elasticsearch
  3. press Enter

To make sure it works, open http://localhost:9200/ in your browser. You should get a JSON response containing name, cluster_name, elasticsearch version etc.

*(On Windows) Open ES_INSTALLATION_DIR\elasticsearch-x.x.x\bin folder, hold Shift key, right click on the folder area and from the drop-down menu select Open command window here.

Filip Savic
  • 2,737
  • 1
  • 29
  • 34
-1

In my case the issue was conflicting version of the elasticsearch that was pulled into my project by the spring-boot-dependencies. If your pom does not inherit from the spring-boot-starter-parent but instead uses dependencyManagement section to import spring-boot-dependencies and you need an older version of the elasticsearch on the classpath then here is the solution: InetSocketTransportAddress. Always run mvn -Dverbose=true help:effective-pom and inspect effective pom for conflicts. -Dverbose=true is critical here. It allows to see where the unwanted dependency is coming from.

Aleksey
  • 149
  • 4