Elasticsearch v5.6.0 working in local not on unix server

In class extending public class NodeIndexer extends ElasticSearchIndexer

private Client init() {
private Client client;
try {

client = new PreBuiltTransportClient(Settings.EMPTY)
					.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300))
					.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9200)); 
			Settings settings = Settings.builder()
					.put("cluster.name", "elasticsearch") // local
					.put("path.home","D:\\Software\\elasticsearch-5.6.0\\bin") //local
					//.put("cluster.name", "my-application")
					//.put("path.home","/usr/share/elasticsearch")
					.put("transport.type","local")
					.put("http.enabled","false")
					.build();

return client;
	}

This is working in local system. But when I deploy same application in unix it's not working.
Following is the large exception from log file.

Caused by: org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{S0q-MVOgQw-JxmNT_LsAug}{localhost}{127.0.0.1:9300}, {#transport#-2}{Ol5YNqpLTAmBoXpxIhra3A}{localhost}{127.0.0.1:9200}]
        at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347) ~[elasticsearch-5.6.0.jar:5.6.0]
        at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245) ~[elasticsearch-5.6.0.jar:5.6.0]
        at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59) ~[elasticsearch-5.6.0.jar:5.6.0]
        at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:363) ~[elasticsearch-5.6.0.jar:5.6.0]
        at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408) ~[elasticsearch-5.6.0.jar:5.6.0]
        at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1256) ~[elasticsearch-5.6.0.jar:5.6.0]
        at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80) ~[elasticsearch-5.6.0.jar:5.6.0]
        at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54) ~[elasticsearch-5.6.0.jar:5.6.0]
        at tv.myplex.services.search.base.BaseSearchDao.indexExists(BaseSearchDao.java:81) ~[content-store-logic-1.0-SNAPSHOT.jar:na]
        at tv.myplex.services.search.ContentSearchDao.<clinit>(ContentSearchDao.java:81) ~[content-store-logic-1.0-SNAPSHOT.jar:na]
        ... 61 common frames omitted

Here is the output from unix

# curl 'http://localhost:9200/'
{
  "name" : "node-1",
  "cluster_name" : "my-application",
  "cluster_uuid" : "wyTjdAh-SUaaxLKdagg_Jw",
  "version" : {
    "number" : "5.6.0",
    "build_hash" : "781a835",
    "build_date" : "2017-09-07T03:09:58.087Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}

This should be enough:

client = new PreBuiltTransportClient(Settings.EMPTY)
					.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));

This is working in local system.

Good.

But when I deploy same application in unix it's not working.

You need to change the cluster.name in that case as it's running with my-application:

Settings settings = Settings.builder()
        .put("cluster.name", "my-application").build();
TransportClient client = new PreBuiltTransportClient(settings)
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
1 Like

Hi Dadoonet,

I'm using org.elasticsearch.client.Client. Not TransportClient.
Is that an issue?

Did update cluster name and ran again. Same issue.

My code check if index already exists and try to create if not.
And I found the following line is where the execution breaks..

IndicesExistsResponse response = client.admin().indices().prepareExists(index).get();

Thank you,
Regards,
SatyaRaj

No it's not an issue.

Could you share the full logs of your elasticsearch instance?

06:08:15.440 [http-bio-8080-exec-1] INFO  t.m.services.search.ContentSearchDao 81 - In CSD static...
06:08:15.441 [http-bio-8080-exec-1] INFO  t.m.s.search.base.BaseSearchDao 80 - Checking if index exists...content in client org.elasticsearch.transport.client.PreBuiltTransportClient@546d3e72
06:08:15.507 [http-bio-8080-exec-1] WARN  n.s.e.constructs.web.filter.Filter 138 - Throwable thrown during doFilter on request with URI: /index/content/v2/content/rebuild-index and Query: nullA MultiException has 2 exceptions.  They are:
1. java.lang.ExceptionInInitializerError
2. java.lang.IllegalStateException: Unable to perform operation: create on com.content.services.backoffice.ContentUpdateService

Caused by: org.glassfish.hk2.api.MultiException: A MultiException has 2 exceptions.  They are:
1. java.lang.ExceptionInInitializerError
2. java.lang.IllegalStateException: Unable to perform operation: create on com.content.services.backoffice.ContentUpdateService

at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:363) ~[hk2-locator-2.2.0-b21.jar:na]
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) ~[hk2-locator-2.2.0-b21.jar:na]
at org.glassfish.jersey.process.internal.RequestScope.findOrCreate(RequestScope.java:158) ~[jersey-common-2.5.1.jar:na]
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2350) ~[hk2-locator-2.2.0-b21.jar:na]
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:612) ~[hk2-locator-2.2.0-b21.jar:na]
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:597) ~[hk2-locator-2.2.0-b21.jar:na]
at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:173) ~[jersey-common-2.5.1.jar:na]
at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:103) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:128) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:110) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:65) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197) ~[jersey-common-2.5.1.jar:na]
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:250) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) ~[jersey-common-2.5.1.jar:na]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) ~[jersey-common-2.5.1.jar:na]
at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[jersey-common-2.5.1.jar:na]
at org.glassfish.jersey.internal.Errors.process(Errors.java:297) ~[jersey-common-2.5.1.jar:na]
at org.glassfish.jersey.internal.Errors.process(Errors.java:267) ~[jersey-common-2.5.1.jar:na]
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:318) ~[jersey-common-2.5.1.jar:na]
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:236) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1010) ~[jersey-server-2.5.1.jar:na]
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:373) ~[jersey-container-servlet-core-2.5.1.jar:na]
... 27 common frames omitted
Caused by: java.lang.ExceptionInInitializerError: null
 at com.content.services.backoffice.ContentUpdateService.<clinit>(ContentUpdateService.java:84) ~[index-logic-1.0-SNAPSHOT.jar:na]
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_111]
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_111]
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_111]
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_111]
 at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1117) ~[hk2-utils-2.2.0-b21.jar:na]
 at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:261) ~[hk2-locator-2.2.0-b21.jar:na]
 at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:337) ~[hk2-locator-2.2.0-b21.jar:na]
 ... 53 common frames omitted
Caused by: org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{9YF9Tu_FRQ-QgstBdaCCvg}{localhost}{127.0.0.1:9300}]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:363) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1256) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:62) ~[elasticsearch-5.6.0.jar:5.6.0]
at com.content.services.search.base.BaseSearchDao.indexExists(BaseSearchDao.java:81) ~[index-logic-1.0-SNAPSHOT.jar:na]
at com.content.services.search.ContentSearchDao.<clinit>(ContentSearchDao.java:82) ~[index-logic-1.0-SNAPSHOT.jar:na]
... 61 common frames omitted

Judging on your logs I don't think you really applied the changes I proposed.
You are still going to localhost:9200

Sorry, old logs. Just edited and updated new logs. Please help.

Can you share the elasticsearch logs please?

None of the elasticsearch log is gets updated, during REST call.
Everything else is just empty after start. Here elasticsearch.log.

[2018-03-27T05:06:55,518][INFO ][o.e.n.Node               ] [node-1] initializing ...
[2018-03-27T05:06:55,652][INFO ][o.e.e.NodeEnvironment    ] [node-1] using [1] data paths, mounts [[/ (/dev/xvda1)]], net usable_space [39.6gb], net total_space [49gb], spins? [no], types [ext4]
[2018-03-27T05:06:55,652][INFO ][o.e.e.NodeEnvironment    ] [node-1] heap size [1.9gb], compressed ordinary object pointers [true]
[2018-03-27T05:06:55,656][INFO ][o.e.n.Node               ] [node-1] node name [node-1], node ID [WbCzvJY2RLGniHC9jUSJlQ]
[2018-03-27T05:06:55,656][INFO ][o.e.n.Node               ] [node-1] version[5.6.0], pid[4220], build[781a835/2017-09-07T03:09:58.087Z], OS[Linux/4.9.58-18.55.amzn1.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_111/25.111-b14]
[2018-03-27T05:06:55,656][INFO ][o.e.n.Node               ] [node-1] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/share/elasticsearch]
[2018-03-27T05:06:56,622][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [aggs-matrix-stats]
[2018-03-27T05:06:56,622][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-common]
[2018-03-27T05:06:56,622][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-expression]
[2018-03-27T05:06:56,622][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-groovy]
[2018-03-27T05:06:56,622][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-mustache]
[2018-03-27T05:06:56,623][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-painless]
[2018-03-27T05:06:56,623][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [parent-join]
[2018-03-27T05:06:56,623][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [percolator]
[2018-03-27T05:06:56,623][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [reindex]
[2018-03-27T05:06:56,623][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty3]
[2018-03-27T05:06:56,624][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty4]
[2018-03-27T05:06:56,624][INFO ][o.e.p.PluginsService     ] [node-1] no plugins loaded
[2018-03-27T05:06:58,773][INFO ][o.e.d.DiscoveryModule    ] [node-1] using discovery type [zen]
[2018-03-27T05:06:59,378][INFO ][o.e.n.Node               ] [node-1] initialized
[2018-03-27T05:06:59,379][INFO ][o.e.n.Node               ] [node-1] starting ...
[2018-03-27T05:06:59,568][INFO ][o.e.t.TransportService   ] [node-1] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2018-03-27T05:07:02,637][INFO ][o.e.c.s.ClusterService   ] [node-1] new_master {node-1}{WbCzvJY2RLGniHC9jUSJlQ}{uv-CvqkYSie9Lf31h97tBw}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2018-03-27T05:07:02,672][INFO ][o.e.g.GatewayService     ] [node-1] recovered [0] indices into cluster_state
[2018-03-27T05:07:02,679][INFO ][o.e.h.n.Netty4HttpServerTransport] [node-1] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2018-03-27T05:07:02,679][INFO ][o.e.n.Node               ] [node-1] started

My bad seems like a space in clustername. My IT team renamed the cluster name and it works as suggested. Thanks.

Note that you can use client.transport.ignore_cluster_name: true in your settings so the TransportClient will ignore that check.

Better, use the Rest Client.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.