TransportClient with Xpack


(Ashok Gadiraju) #1

I am using the x-pack-transport client for connecting to ES cluster with x-pack installed.

Settings esSettings = Settings.builder().put("cluster.name", EsClusterName)
.put("xpack.security.user", "username:passwrd")
.build();

TransportClient client =
new PreBuiltXPackTransportClient(esSettings)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(EsHost), 9300));

I am facing this error when I try to run this

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.Client]: Factory method 'client' threw exception; nested exception is ElasticsearchException[Failed to load plugin class [org.elasticsearch.xpack.XPackPlugin]]; nested: ElasticsearchException[No constructor for [class org.elasticsearch.xpack.XPackPlugin]. A plugin class must have either an empty default constructor or a single argument constructor accepting a Settings instance];
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
... 98 common frames omitted
Caused by: org.elasticsearch.ElasticsearchException: Failed to load plugin class [org.elasticsearch.xpack.XPackPlugin]
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:438) ~[elasticsearch-5.6.9.jar:5.6.9]
at org.elasticsearch.plugins.PluginsService.(PluginsService.java:104) ~[elasticsearch-5.6.9.jar:5.6.9]
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:104) ~[elasticsearch-5.6.9.jar:5.6.9]
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:129) ~[elasticsearch-5.6.9.jar:5.6.9]
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:268) ~[elasticsearch-5.6.9.jar:5.6.9]
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:133) ~[transport-5.6.9.jar:5.6.9]
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:58) ~[x-pack-transport-6.1.4.jar:6.1.4]
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:53) ~[x-pack-transport-6.1.4.jar:6.1.4]
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:49) ~[x-pack-transport-6.1.4.jar:6.1.4]
at com.optum.voyager.elasticsearch.elasticsearchapi.config.ElasticSeachConfig.client(ElasticSeachConfig.java:54) ~[classes/:na]
at com.optum.voyager.elasticsearch.elasticsearchapi.config.ElasticSeachConfig$$EnhancerBySpringCGLIB$$74dd8423.CGLIB$client$0() ~[classes/:na]
at com.optum.voyager.elasticsearch.elasticsearchapi.config.ElasticSeachConfig$$EnhancerBySpringCGLIB$$74dd8423$$FastClassBySpringCGLIB$$eecb12bb.invoke() ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at com.optum.voyager.elasticsearch.elasticsearchapi.config.ElasticSeachConfig$$EnhancerBySpringCGLIB$$74dd8423.client() ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_152]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_152]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_152]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_152]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
... 99 common frames omitted
Caused by: org.elasticsearch.ElasticsearchException: No constructor for [class org.elasticsearch.xpack.XPackPlugin]. A plugin class must have either an empty default constructor or a single argument constructor accepting a Settings instance
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:432) ~[elasticsearch-5.6.9.jar:5.6.9]
... 118 common frames omitted


(David Pilato) #2

You are mixing elasticsearch 5.6.9 and Transport client with xpack 6.1.4


(Ashok Gadiraju) #4

This helped me with compile time errors. Now during runtime , I am getting this error when i try to use spring data repository of elastic search to save index.

java.lang.NoSuchMethodError: org.elasticsearch.action.index.IndexRequestBuilder.setSource(Ljava/lang/String;)Lorg/elasticsearch/action/index/IndexRequestBuilder;
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.prepareIndex(ElasticsearchTemplate.java:1034) ~[spring-data-elasticsearch-3.0.7.RELEASE.jar:3.0.7.RELEASE]
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.index(ElasticsearchTemplate.java:550) ~[spring-data-elasticsearch-3.0.7.RELEASE.jar:3.0.7.RELEASE]
at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.save(AbstractElasticsearchRepository.java:156) ~[spring-data-elasticsearch-3.0.7.RELEASE.jar:3.0.7.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_152]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_152]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_152]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_152]
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:377) ~[spring-data-commons-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:629) ~[spring-data-commons-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:593) ~[spring-data-commons-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:578) ~[spring-data-commons-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at

Also , on other note as I am not able to use RestHighlevelClient or RestClient with spring data yet, snd planning to move away from sprig data. Can you let me know the performance comparisions of high level vs low level clients


(David Pilato) #5

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.

May be Spring data is not compatible yet with ES version 6.x?

Can you let me know the performance comparisions of high level vs low level clients

No difference. The HLClient just parses the request and response objects but that does not change the query ran on the cluster.


(system) #6

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