Fail to connect Java api and elasticsearch

Hi I have wrote a java program to perform CRUD operation and now when I tried running my code First I got this on the console window :- "Started Application in 8.539 seconds (JVM running for 9.069)" and later just after this line I got a error message:- "[Glob] failed to get node info for {#transport#-1}{127.0.0.1}{127.0.0.1:9201}, disconnecting..., followed by many other error like failed to load elasticsearch nodes". I have attached a snapshot as well for more clearification. Also I have tried fixing the error.

More info:- I am using elasticsearch 2.4.0, using spring tool suite as IDE.

Kindly, help me.

Best regards,
Vivek Ranjan

Please don't post images of text as they are hardly readable and not searchable.

Instead paste the text and format it with </> icon. Check the preview window.

I don't see your code but I believe you used the wrong port here.

Ok I will paste the code here. Thanks for reverting back. The issue is I have 2 laptop and on one laptop same piece of code is working fine but when I import the code in this PC it's not working here.
Thanks.

 :: Spring Boot ::        (v1.5.1.RELEASE)

2018-07-24 13:03:38.787  INFO 4500 --- [           main] com.elasticsearch.Application            : Starting Application on WIN7PRO-64-40 with PID 4500 (D:\Vivek\springboot-elasticsearch-example\springboot-elasticsearch-example\target\classes started by vivek in D:\Vivek\springboot-elasticsearch-example\springboot-elasticsearch-example)
2018-07-24 13:03:38.790  INFO 4500 --- [           main] com.elasticsearch.Application            : No active profile set, falling back to default profiles: default
2018-07-24 13:03:38.975  INFO 4500 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3444d69d: startup date [Tue Jul 24 13:03:38 IST 2018]; root of context hierarchy
2018-07-24 13:03:39.638  INFO 4500 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'elasticsearchTemplate' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=esConfig; factoryMethodName=elasticsearchTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/elasticsearch/config/EsConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration; factoryMethodName=elasticsearchTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.class]]
2018-07-24 13:03:39.910  INFO 4500 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration' of type [class org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-24 13:03:40.067  INFO 4500 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'validator' of type [class org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-24 13:03:40.279  INFO 4500 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 9000 (http)
2018-07-24 13:03:40.289  INFO 4500 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2018-07-24 13:03:40.290  INFO 4500 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.11
2018-07-24 13:03:40.367  INFO 4500 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-07-24 13:03:40.368  INFO 4500 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1435 ms
2018-07-24 13:03:40.514  INFO 4500 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-07-24 13:03:40.514  INFO 4500 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-24 13:03:40.514  INFO 4500 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-24 13:03:40.514  INFO 4500 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-24 13:03:40.514  INFO 4500 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-24 13:03:40.686  INFO 4500 --- [           main] org.elasticsearch.plugins                : [Mercurio] modules [], plugins [], sites []
2018-07-24 13:03:41.297  INFO 4500 --- [           main] org.elasticsearch.client.transport       : [Mercurio] failed to get node info for {#transport#-1}{127.0.0.1}{127.0.0.1:9300}, disconnecting...

org.elasticsearch.transport.NodeDisconnectedException: [][127.0.0.1:9300][cluster:monitor/nodes/liveness] disconnected

2018-07-24 13:03:41.442 ERROR 4500 --- [           main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{127.0.0.1}{127.0.0.1:9300}]
2018-07-24 13:03:41.709  INFO 4500 --- [           main]

format it with </> icon. Check the preview window.

Is elasticsearch running on your local machine?

Yes it is working now. The issue was, I had 2 different versions of elasticsearch in my PC and then I was trying to run my code. Now I have deleted the 6.3.1 version of it and it is working fine. Thanks for your help :smile:

@dadoonet
I have one more doubt, I wanna run this application using elasticsearch 6.X.X version(latest) so can you please guide me the way to achieve it. I have tried it but was getting the shared error alongwith the elasticsearch version is not compatible.

Thanks.

I don't really know how to fix that on Spring boot side.
May be you have to overwrite the default transport client which is defined by Spring?

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